I recently switched my init system on my ARM box running Linux 2.6 from sysvinit to runit with great success. However, I'm trying to fine-tune the initialization routine. I'd like to have something similar to a 'oneshot' systemd service.
Part of the initialization routine is that a disk may have to be formatted, and then must be mounted. One of the runit services depends on this disk being mounted. However, the rest of the services (e.g. sshd) do not. Therefore, it would be nice if I could start the disk format procedure in the background while the rest of the system initializes. The disk format is fairly slow, so it could make a major difference in the total boot time if it could be done in the background.
I have a disk formatting script /usr/local/bin/format_disk.sh
, that reliably formats the disk if it's not already formatted (it's a no-op if it's already formatted). These are the options I'm considering currently:
- Run
sudo /usr/local/bin/format_disk.sh
manually: this is what I'm doing now, but I'd like to automate the process so that I can expect my system to fully initialize without user intervention. - Run
/usr/local/bin/format_disk.sh
in the script/etc/runit/1
: this isn't ideal since it blocks services from starting until the disk is formatted. - Make a runit service that runs
/usr/local/bin/format_disk.sh
and then terminates / loops / etc.: this isn't ideal since it's not a real daemon that has to stay up for the duration of the system uptime. Maybe I can make it runsv stop
on itself?
It would be nice if I could do something like /usr/local/bin/format_disk.sh &
in /etc/runit/1
, but I suspect that runit still won't start services until format_disk.sh
terminates. Is this suspicion correct? Is there some other way to start a background process in /etc/runit/1
that will allow services to start?
What is the best way to run an initialization step in the background on a runit system?