runit init under alpine linux

6 posts / 0 new
Last post
#1 Fri, 2015-08-28 17:44
mrgreen
  • mrgreen's picture
  • Offline
  • Last seen: 9 months 2 weeks ago
  • Joined: 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

Mon, 2015-08-31 09:07
mrgreen
  • mrgreen's picture
  • Offline
  • Last seen: 9 months 2 weeks ago
  • Joined: 2015-07-08

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...

Sat, 2015-09-26 17:06
Slacky
  • Slacky's picture
  • Offline
  • Last seen: 2 years 5 months ago
  • Joined: 2015-09-26

care to link that guide?

Sounds interesting

Tue, 2015-10-13 19:09
ddt
  • ddt's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-10-06

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.

Thu, 2015-10-29 16:07
ddt
  • ddt's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-10-06

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

http://dl-2.alpinelinux.org/alpine/v3.2/main
@edge <a href="http://dl-2.alpinelinux.org/alpine/v3.2/edge/main
@testing" rel="nofollow">http://dl-2.alpinelinux.org/alpine/v3.2/edge/main
@testing</a> <a href="http://dl-2.alpinelinux.org/alpine/v3.2/edge/testing
" rel="nofollow">http://dl-2.alpinelinux.org/alpine/v3.2/edge/testing
</a>

*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

# touch /etc/runit/1 && cat 'EOF' > /etc/runit/1
#!/bin/sh
RUNLEVEL=S /sbin/rc sysinit
RUNLEVEL=S /sbin/rc boot
RUNLEVEL=S /sbin/rc default
## Optional - Something simple and esoteric just to check whether or not runit-init was used over sysvinit 
RUNLEVEL=S echo "I'm sorry Dave, I afraid I can't do that..."
EOF

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.

Sun, 2015-11-01 10:00
mrgreen
  • mrgreen's picture
  • Offline
  • Last seen: 9 months 2 weeks ago
  • Joined: 2015-07-08

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...

Log in or register to post comments