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:

  1. 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.
  2. 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.
  3. 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 run sv 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?

1 Answer 1


Two options:

  1. Call the script from the run script of the dependent service. This will ensure the script returns before the service is run.
  2. Run the script in the background from /etc/rc.local, and have the script touch a tmpfs file when it is done running. Then in the dependent service's run script, check that said file exists.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .