runit init under alpine linux
#1
Fri, 2015-08-28 17:44
mrgreen
-
- Offline
- 9 months 2 weeks ago
- 2015-07-08
I am really loving my new alpine linux install, really want to try out runit init, notice that /sbin/init is linked too /bin/busybox (inittab points to rc). Is there a way to get runit as init?
Openrc is not a problem but it was very slow on networking and cronyd, could run parallel but not sure it if is a good idea.
Mr Green
After searching have found gentoo wiki guide for running runit under openrc. Find it odd that alpine busybox does not contain runit commands, would have reduced size of image even more. Still not a dealbreaker loving Alpine...
care to link that guide?
Sounds interesting
Seems straightforward going by https://wiki.gentoo.org/wiki/Runit#PID_1_.E2.80.94_init_replacement
I don't know how much smaller the Runit library is than SysV & OpenRC, but it's interesting to say the least. I think I'll give this a shot on a VM soon.
Using runit-init to bootstrap OpenRC is fairly simple, the only thing you need is the testing repository.
Here's how to do it on a fresh install:
0a - Add or mask the testing repo in /etc/apk/repositories if you haven't already. Here's what mine looks like:
# cat /etc/apk/repositories
*Formatting is acting wonky here
0b - Update apk
# apk --update upgrade
1 - Install runit
# apk add runit@testing
2 - Create a directory for runit in /etc if it's not already there
# mkdir /etc/runit
3 - Create the default runlevel
4 - Make the default runlevel executable
# chmod +x /etc/runit/1
5 - Test to see if runit-init is working Either reboot and append init=/sbin/runit-init to your kernel's command line or run the new default runlevel directly with:
# /etc/runit/1
Either should bring OpenRC up into the sysinit runlevel through the default runlevel. If you added some text at the end of your /etc/runit/1 like I did, you should see that directly after OpenRC's dialogue. Not necessary at all, but a nice little reminder while I still have both init systems installed.
To replace OpenRC entirely, you'll need to go through the startup scripts that you depend on and start from the very bottom and make your way to the top-level services. This is where I am at the moment and haven't gone much further yet.
I'll be slowly making my way through this and if I get anything decent together I'll be happy to share. Regardless, this is very doable and anything that simply cannot be done or figured out through runit can easily be bootstrapped through OpenRC. My scripting/programming background isn't very deep, but runit seems to be extremely straightforward for both initialization and supervisor scripting.
Now that I think about it, I may just take a look at Void Linux's runit scripts for some inspiration on the more sensitive aspects of the init process.
Life could be made so much easier if alpine shipped busybox with runit support, you would only then need runit scripts (possibly from void) to boot and not have to install anything else.
You are of course right it is not that difficult to use your approach, with recent events in busybox dropping systemd support. It might be possible to ship busybox with runit with no real overheads...