Skip to content

QuentinPerez/dainit

 
 

Repository files navigation

dainit

dainit is a simple init system for Linux written in Go, mostly for me to to use on my laptop. It's likely less full-featured and more minimalist than your init system. (It aims to be an init system and only an init system.)

dainit will do the following:

  1. Set the hostname
  2. Remount the root filesystem[1]
  3. Mount all other non-network filesystems and activate swap partitions
  4. Start processes with config files in /etc/dainit after their dependencies ("Needs") are started. See conf/ for a sample udevd and wpa_supplicant (which depends on udevd to finish before being started) config.
  5. Start a tty and wait for a login.
  6. Kill running processes, unmount filesystems, and poweroff the system once that login session ends.

(The way step 4 is handled isn't very elegant and will likely fail if you have too many slow startup processes.)

You can also create a file /etc/dainit.conf for some basic configuration. If there are any lines of the form "Autologin: username" it will automatically log in as that username. (If there's multiple autologin directives, it will create the appropriate number of ttys.) If any line contains "Persist: true", then when a tty exits, it'll respawn the tty instead of powering down the system once all the ttys are gone.

Installation/Usage

sudo cp $GOPATH/bin/dainit /sbin
sudo update-initramfs -u

then add init=/sbin/dainit to your grub configuration. (Or alternatively, make /sbin/init a symlink to dainit.)

[1] This shouldn't be required, since mount -a should take care of it in step 3 according to mount(8), but as far as I can tell it doesn't.

About

A simple pure-Go Linux init system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%