In a traditional SysV init system, differently configured runlevels can be
chosen at boot time. Some distributions, including ubuntu, are migrating to the "upstart" init system. Most services and daemons are still provided with the older SysV style startup scripts. Upstart maintains compatibility with these services by running their scripts at boot time as they would be under the init startup system.
In ubuntu systems, a casualty of this migration is that runlevels no longer work entirely
as expected. Emmet Caulfield has an explanation
and a solution on
this blog page. Using the script he provides, the kernel command line is scanned at boot time
for the expression init N, where N is a number signifying
the desired runlevel.
Most distributions and some older versions of ubuntu will boot
into a non-default runlevel by appending a single numerical
digit (or 'S' for single user mode) to the end of the bootloader
kernel command line. This /etc/event.d/rc-default can be
used instead of the file provided in the above link to make ubuntu
follow that convention.
# rc - runlevel compatibility
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
#
# Edited to support booting to non-default runlevel by adding a
# single digit from [2345] as last option on kernel command line
# at boot. See elif statement below. lsw 10/4/2008
#
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif RL="$(grep -o "[[:blank:]][2345]$" /proc/cmdline || true)"; then
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
If you want to try it, save a copy of your original
/etc/event.d/rc-default file in some other directory on
your system. Please read the warnings in
Emmet Caulfields's blog.
I won't repeat them all here, but make sure you have another way to boot
your system and can edit the rc-default file if necessary. Copy and paste or
download the file to your system.
From the directory where you have saved the new file,
sudo cp rc-default /etc/event.d
In a default ubuntu installation, runlevels 2,3,4 and 5 are all configured
alike. 2 is the default startup runlevel in ubuntu, so modify 3,4, or 5 for
the configuration you will use less frequently. Add an appropriate boot
stanza to /boot/grub/menu.lst to make the alternate runlevel
a choice at boot time. The
Illustrated Dual Boot site is a great reference for working with grub.
Probably the most common non-default runlevel is one configured to use text mode only, i.e. no X server or gui. See Editing Runlevels for more information.
* * *
If you would rather not modify /etc/event.d/rc-default
and /boot/grub/menu.lst,
and only rarely need a different runlevel, here is an alternate method.
* * *
The man pages for telinit and init and the readme files in
/usr/share/doc/sysv-rc and /usr/share/doc/upstart provide some explanation
of how runlevels, init, and upstart work.