- C 100%
| docs | ||
| minit.c | ||
| README.md | ||
minit - Minimal Init System
Version: 1.0.1
A lightweight, reliable init system for Linux with service supervision, automatic filesystem repair, and network configuration.
Features
- 🛠️ Service Supervision - Automatic service restart on failure
- 📁 Auto Filesystem Repair - Automatic fsck with retry mechanism
- 🌐 Network Setup - Automatic interface initialization
- 📦 Kernel Modules - Auto-loading of 65+ essential modules
- 🔌 Device Management - udevd integration
- ⚡ Clean Shutdown - Graceful service termination
- 📝 Service Logging - Automatic logging to /var/log/minit.log (max 100 lines)
- 💾 UEFI Support - Automatic efivarfs mounting for UEFI systems
Requirements
Required Dependencies
| Package | Provides |
|---|---|
clang or gcc |
C compiler |
musl or glibc |
C library (static linking) |
util-linux |
mount, fsck |
kmod |
modprobe, lsmod |
iproute2 |
ip command |
busybox or coreutils |
Basic utilities |
Optional Dependencies
| Package | Purpose |
|---|---|
dhcpcd or dhclient |
DHCP client |
udev or eudev |
Device manager |
agetty |
Terminal manager |
NetworkManager |
Network management |
Installation
Compilation
# Static build (recommended)
clang -static minit.c -o minit
# Or with gcc
gcc -static minit.c -o minit
# Dynamic build
clang minit.c -o minit
Setup as Init
# Copy to /sbin
sudo cp minit /sbin/init
# Or use as custom init
sudo cp minit /sbin/minit
# Update GRUB (optional)
# Add to /etc/default/grub:
# GRUB_CMDLINE_LINUX="init=/sbin/minit"
sudo update-grub
# Reboot
sudo reboot
⚠️ Warning: Test minit thoroughly before using as primary init. Always have a rescue option.
Usage
Service Structure
/etc/minit/
├── sv/ # Service definitions
│ ├── getty-tty1/
│ │ └── run
│ └── ...
└── service/ # Enabled services (symlinks)
├── getty-tty1 -> ../sv/getty-tty1
└── ...
Creating a Service
# Create service
mkdir -p /etc/minit/sv/myservice
cat > /etc/minit/sv/myservice/run << 'EOF'
#!/bin/sh
exec /usr/bin/mydaemon -f
EOF
chmod +x /etc/minit/sv/myservice/run
# Enable
mservice enable myservice
mservice Commands
| Command | Description |
|---|---|
add <name> <cmd> |
Add new service |
enable <name> |
Enable service |
disable <name> |
Disable service |
start <name> |
Start service |
stop <name> |
Stop service |
restart <name> |
Restart service |
check <name> |
Check status (exit 0/1) |
list |
List all services |
poweroff |
Power off system |
reboot |
Reboot system |
Examples
# Check service
mservice check dbus
echo $? # 0=running, 1=stopped
# Control services
mservice start nginx
mservice stop nginx
mservice restart nginx
# Power management
mservice poweroff
mservice reboot
Kernel Modules
Module Sources (in order)
/etc/modules-load.d/*.conf/etc/modprobe.d/*.conf/etc/modules- Built-in database (65+ modules)
Built-in Modules
Filesystems: ext4, ext3, ext2, xfs, btrfs, f2fs, vfat, ntfs, ntfs3
Network: e1000, e1000e, r8169, r8125, virtio_net, mlx5_core
WiFi: rfkill, rfkill-gpio, cfg80211, mac80211
Storage: ahci, usb_storage, sd_mod, dm_mod, raid1
Example Configuration
# /etc/modules-load.d/network.conf
e1000
r8169
virtio_net
# /etc/modprobe.d/wifi.conf
blacklist rtw88_8822bu
options 88x2bu rtw_switch_usb_mode=0 rtw_led_ctrl=1
Network
minit automatically:
- Mounts /sys and /proc
- Starts udevd
- Brings up all interfaces (lo, eth*, enp*, ens*, wlan*)
- Supports DHCP
Network Service Example
# /etc/minit/sv/network/run
#!/bin/sh
sleep 3
ip link set lo up
ip link set eth0 up
exec dhcpcd -B eth0
WiFi Service Example
# /etc/minit/sv/wifi/run
#!/bin/sh
modprobe cfg80211
modprobe mac80211
modprobe 88x2bu
ip link set wlan0 up
exec wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -O /var/run/wpa_supplicant
Shutdown Process
- Send SIGTERM to all services
- Wait 5 seconds for graceful termination
- Send SIGKILL to remaining processes
- Sync disks
- Unmount filesystems
- Execute reboot/poweroff
Logging
minit automatically logs service events to /var/log/minit.log (or /tmp/minit.log):
- Service startup (only first start, not respawns)
- Service exit and respawn events
- Log rotation: maximum 100 lines
View Logs
# View live
tail -f /var/log/minit.log
# View last 50 lines
tail -50 /var/log/minit.log
Example Log Output
=== minit started (PID 1) ===
[minit] Started /etc/minit/service/getty-tty1/run with PID 501
[minit] Started /etc/minit/service/getty-tty2/run with PID 502
[minit] Service /etc/minit/service/getty-tty1/run (PID 501) exited. Respawning...
UEFI Support
minit automatically mounts efivarfs on UEFI systems:
/sys/firmware/efi/efivars
On BIOS systems, this mount is silently skipped.
Shutdown Output
[minit] === SYSTEM SHUTDOWN INITIATED ===
[minit] Reason: REBOOT
[minit] Stopping services...
[minit] Stopping service 1/6: /etc/minit/service/getty-tty1/run (PID 501) ... done
[minit] Waiting up to 5 seconds for services to stop...
[minit] All services stopped successfully
[minit] Syncing disks...
[minit] Unmounting filesystems...
[minit] *** REBOOTING SYSTEM ***
Default Services
minit creates 6 getty services by default:
- getty-tty1 (Ctrl+Alt+F1)
- getty-tty2 (Ctrl+Alt+F2)
- getty-tty3 (Ctrl+Alt+F3)
- getty-tty4 (Ctrl+Alt+F4)
- getty-tty5 (Ctrl+Alt+F5)
- getty-tty6 (Ctrl+Alt+F6)
Documentation
Quick Links
| Document | Description |
|---|---|
| Quick Start | Get started in 5 minutes |
| Troubleshooting | Common issues and solutions |
| Migration Guide | Switch from systemd/sysvinit |
| Service Examples | Ready-to-use service scripts |
| API Reference | Complete technical reference |
| Changelog | Version history |
License
MIT License - See LICENSE file for details.
Contributing
- Fork the repository on Codeberg: https://codeberg.org/faron/Minit
- Create a feature branch
- Make your changes
- Submit a pull request
Support
For issues and questions, please open an issue on Codeberg: https://codeberg.org/faron/Minit/issues
minit - Built with simplicity and reliability in mind.
© 2026