s6-linux-init
Software
skarnet.org

Quickstart and FAQ for s6-linux-init

Quickstart

  1. Install all the s6-linux-init dependencies:
  2. Save and remove your old /etc/s6-linux-init directory, if you have one.
  3. Install s6-linux-init itself.
  4. Save your old /sbin/init, /sbin/telinit, /sbin/shutdown, /sbin/halt, /sbin/poweroff and /sbin/reboot binaries.
  5. Make sure you have a /run directory.
  6. Edit the scripts in /etc/s6-linux-init/skel.
  7. Check that your devtmpfs is automounted by your kernel at boot time. If it is not, add the -d /dev option to the s6-linux-init-maker command line below.
  8. As root, run:
         rm -rf /tmp/blah
         s6-linux-init-maker -1 -G "/sbin/getty 38400 tty1" /tmp/blah
         rm -rf /etc/s6-linux-init/current
         mv /tmp/blah /etc/s6-linux-init/current
         cp -a /etc/s6-linux-init/current/bin/* /sbin/ 
  9. Reboot. Warning: use your old reboot command, that you saved, not the new one that has just been created by s6-linux-init-maker, because you're still running on your old init system and need to use a reboot command that matches it.
  10. After the reboot: congratulations! your machine is now running an s6-based init system.
  11. To shut the machine down, use /sbin/shutdown, /sbin/halt, /sbin/poweroff or /sbin/reboot as usual.

FAQ

How do I convert a runit setup to an s6 one?

A runit and an s6 setup are very similar. There are just three things you need to pay attention to:

In a runit setup, you have the runit program running as pid 1, and sequentially spawning /etc/runit/1, then /etc/runit/2 which contains the invocation of runsvdir, and finally /etc/runit/3 at shutdown time when runsvdir is dead.

In a s6 setup that you have booted via s6-linux-init, the scanner, s6-svscan (the equivalent of runsvdir), runs as pid 1, very early, and remains there for the whole lifetime of the machine. At boot time, the /etc/s6-linux-init/current/scripts/rc.init script is run, with the supervision tree already in place; when it exits, the system is supposed to be in a fully-booted, stable state. At shutdown time (on receipt of a shutdown command), the /etc/s6-linux-init/current/scripts/rc.shutdown script is run, with the supervision tree still in place; when it exits, the filesystems will be unmounted and the machine will be rebooted and/or stopped.

So, the quickest way to port a runit setup to an s6-linux-init one is to:

Once you have done that, you have a literal translation of your runit system into a s6 system, and it should boot, and work, albeit in a non-idiomatic, unoptimized way. If you don't want to overwrite your /sbin/init binary, you can boot with init=/etc/s6-linux-init/current/bin/init as a kernel command line argument to reach the s6-linux-init entry point.

Further work to make the setup prettier can include:

Colin Booth has a series of posts on Reddit that go into more detail on how to use a Void Linux distribution, which natively uses runit, with the s6 ecosystem instead; there are step-by-step tutorials as well as turnkey solutions, and it is recommended reading even if you do not use Void.