Setting up s6 on Gentoo II S. Gilles 2017-03-25 As I mentioned, I really like s6. I had some time off, so I decided to convert my heavy-duty desktop (my lightweight laptop is already converted) using the steps I followed. Here are some of the caveats I found with my guide: o Make sure your kernel has input modules compiled in. My desktop, for example, had usbhid as a module, which made interacting via keyboard difficult. I never noticed on my laptop because I don't use usb peripherals there. o Make sure that your kernel commandline specifies that the root partition is rw. This is because of the “ln -sf /proc/mounts /etc/mtab” line in /etc/rc.init. I never noticed on my laptop because it uses an odd, baked-in bootloader that happens to set rw. In case you happen to be using the excellent extlinux bootloader, my relevant config entry is: LABEL kernel-mainline-s6 MENU LABEL kernel-mainline [s6] KERNEL ../kernel-mainline APPEND root=/dev/sda3 rw init=/sbin/init.s6 o Make sure /etc/rc.init is +x! The same goes for /etc/rc.tini, but the init is more noticable. o My device-ownership target (the thing which set /dev/fb0 to have the correct ownership) needed many, many more entries. After adding entries for video, audio, tty, etc. I began to realize I was doing it completely wrong. Instead, I needed to run ‘udevadm trigger’ after udev was up and initialized. This magically lets X11 and friends work. I can't seem to figure out exactly when this needs to be called, however, so I have a ‘udev-settled’ target that runs #!/bin/execlineb -P foreground { udevadm settle } foreground { udevadm trigger } foreground { udevadm settle } foreground { sleep 10 } foreground { udevadm trigger } foreground { sleep 10 } foreground { udevadm trigger } That certainly does it, although it makes me want to wash my hands. o ALSA starts out muted. There's a whole fancy script to save and restore volume levels provided by alsa-utils, but I just want it on, so my alsa target looks like #!/bin/execlineb -P exec -c redirfd -a 2 /dev/null redirfd -a 1 /dev/null foreground { amixer -c 1 sset Master Playback 80 } foreground { amixer -c 1 sset Master on } I think the card is specific to my system. o In my previous writeup, I completely forgot to mention the /etc/rc.shutdown script. It's rather important (compare /sbin/init and rc.init with rc.init and /etc/rc.shutdown). Again, the default worked just fine for me. Note that the ‘s6-${1}’ call at the end is the s6 equivalent of ‘halt’ or ‘shutdown’ or whatever other init systems call the program that contains magic. #!/bin/execlineb -S0 foreground { s6-echo "Syncing disks." } foreground { s6-sync } foreground { s6-echo "Sending all processes the TERM signal." } foreground { s6-nuke -th } s6-sleep 2 foreground { s6-echo "Sending all processes the KILL signal." } foreground { s6-nuke -k } wait { } foreground { s6-echo "Syncing disks." } foreground { s6-sync } foreground { s6-echo "Unmounting disks." } foreground { mount -o ro,remount / } # Havoc is played with this, since the kernel is responsible for the devtmpfs # foreground { s6-umount -a } foreground { s6-echo "\nPerforming ${1}.\n" } s6-${1} -f So now my hulking desktop, which used to take a good minute to start up (can't log in until the local test instance of nginx is fully initialized!) has a 17 second BIOS-to-X11 time. That's pretty good.