On Sat, 2 Aug 2014 17:01:15 -0700 James Powell <[email protected]> wrote:
> Over at our project we imported a utility from VoidLinux that handles > the halt functions and a special shutdown script also. I'm curious if > we could import and adapt it officially into Runit if only for > completionary purposes. Shutdown *scripts* go into stage 3 and you can use them right now with runit. This stage 4 - hand-off is only necessary for things that need to run in pid1, for example see hddown.c in sysvinit sources. That part of program needs to load everything necessary into memory so there is nothing accessing the storage anymore and does HDIO_DRIVE_CMD ioctl to spindown the drives - to make sure all the write caches were flushed just before it halts the machine. On the other hand, it seems that shutting down from initrd is the default way now on systemd/dracut systems: https://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html#_dracut_on_shutdown and I guess it makes sense nowadays with enough space on tmpfs to do device shutdowns from there as you don't have to worry that you'll cut the branch you're sitting on. And such hand-off would be necessary to get pid1 out of the former root.
