Adding Runlevels

From ArchWiki

Jump to: navigation, search


First method

To create another runlevel in Arch:

# cd /etc
# cp rc.multi rc.multi5
# sed -i "s/DAEMONS/DAEMONS5/g" /etc/rc.multi5

Then add it to /etc/inittab by changing:

rm:2345:wait:/etc/rc.multi

to

rm:234:wait:/etc/rc.multi
rm:5:wait:/etc/rc.multi5

Then put daemons into DAEMONS5=() in your /etc/rc.conf.

This setup will not be clobbered by any further system updates, though it might be nice if someone packaged it up, with /etc/rc.multi5 and an /etc/inittab.example

Another way, without adding any symlink

With a simple modification on /etc/rc.multi, runlevels can be simply added by adding a new DAEMONS line in /etc/rc.conf. (Check out the files at [1])

Here's the patch:

--- rc.multi	2008-06-22 23:58:29.000000000 +0200
+++ rc.multi.new	2008-06-23 00:14:05.000000000 +0200
@@ -11,8 +11,25 @@
 # Load sysctl variables if sysctl.conf is present
 [ -r /etc/sysctl.conf ] && /sbin/sysctl -q -p &>/dev/null
 
+# Load the appropriate DAEMONS array according to runlevel specified in the kernel boot cmdline
+RUNLEVEL=""
+FINAL_DAEMONS=()
+ 
+for param in `cat /proc/cmdline`; do
+  param_rl=`echo $param | grep ^runlevel`
+  if [ ! "$param_rl" = "" ]; then
+    RUNLEVEL=`echo $param_rl | sed -r -e "s#runlevel=(.+)#\1#"`
+  fi
+done;
+
+if [ "${RUNLEVEL}" = "" ]; then
+	eval FINAL_DAEMONS=(${DAEMONS[@]})
+else
+	eval FINAL_DAEMONS=(\${DAEMONS_${RUNLEVEL}[@]})
+	if [ "${#FINAL_DAEMONS[@]}" = "0" ]; then
+		eval FINAL_DAEMONS=(${DAEMONS[@]})
+	fi	
+fi
+
 # Start daemons
-for daemon in "${DAEMONS[@]}"; do
+for daemon in "${FINAL_DAEMONS[@]}"; do
 	if [ "$daemon" = "${daemon#!}" ]; then
 		if [ "$daemon" = "${daemon#@}" ]; then
 			/etc/rc.d/$daemon start

Now, to add a runlevel, add a new array in /etc/rc.conf (in this example I named it FOO):

DAEMONS_FOO=( ...whatever... )

and to run the system with this runlevel, simply add runlevel=FOO to your boot arguments in LILO or GRUB.

Personal tools