custom runlevels on gentoo openrc

with openrc, the magic term is ’stacked runlevels’

suppose you have a server with sophisticated storage capabilities that you don’t always want to come up on boot. if, for example, booting in a recovery mode to poke around.

you could easily enough just add all the services to the default runlevel and set up a bunch of lines in /etc/rc.conf to make your services depend (use/need) on a central ’storage’ service.

so yeah, i’ve done that, but i also still don’t want my services to start automatically. in this particular case, i actually want to have to manually start things after confirming other things.

so…enter stacked runlevel, allowing me to easily start a set of services.

set up new runlevel:

# 'create' a runlevel called 'storage'
mkdir /etc/runlevels/storage  
# add the 'default' runlevel to the new runlevel
rc-update -s add default storage  
on boot, post-verify:

rc storage  

seems like it would have issues scaling to a variety of runlevel needs, but that’s why people use systemd. ’stacking’ works well ‘up’, not so great laterally.