Theoretically, if Ubuntu were compliant with UNIX and Linux standard, adding '3' to grub's 'kernel' command in /boot/grub/menu.lst should have been sufficient, because runlevel '3' means no 'X11' according to this standard.
Unfortunately, Ubuntu has ignored the standard and that's why you'll need to change /etc/init/lightdm.conf or /etc/init/gdm.conf (or whatever DM you use) as well. This is how mine "on start" condition looks like:
start on ((filesystem
and runlevel [!06]
and runlevel [!03]
and started dbus
and plymouth-ready)
or runlevel PREVLEVEL=S)
In Grub's menu.lst I've also added a menu item that allows me to boot to runlevel 3:
title Ubuntu 11.10 Server No UI, kernel 3.0.0-32-generic-pae
root (hd0,0)
kernel /vmlinuz-3.0.0-32-generic-pae root=UUID=your-root-disk-id 3 ro
initrd /initrd.img-3.0.0-32-generic-pae
quiet
title Ubuntu 11.10, kernel 3.0.0-32-generic-pae
root (hd0,0)
kernel /vmlinuz-3.0.0-32-generic-pae root=your-root-disk-id ro
initrd /initrd.img-3.0.0-32-generic-pae
quiet
Now I can chose between booting to runlevel 5 with X11 or to runlevel 3 without it.
The problem with adding an entry using 40_custom
is that the entry is static - the contents are copied as-is to grub.cfg
, so a new kernel requires re-editing that file. With very slight tinkering of the 10-linux
, you can get update-grub
to generate an additional entry for each of the installed kernels. Edit /etc/grub.d/10_linux
, and after the lines where it says:
linux_entry "${OS}" "${version}" advanced \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}" "${version}" recovery \
"${GRUB_CMDLINE_LINUX_RECOVERY} ${GRUB_CMDLINE_LINUX}"
fi
Add another call to linux_entry
:
linux_entry "${OS}, runlevel 3" "${version}" advanced \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT} 3"
(Selecting a runlevel is as simple as tacking on the number at the end of the options, IIRC.)
Effect:
Menu entry in the "Advanced options" sub menu:
The contents of that entry:
Of course, normally runlevels 2-5 are equivalent, so booting from it made no difference to me, except:
$ runlevel
N 3
Best Answer
The simpler way is to edit
/etc/init/rc-sysinit.conf
and change:To:
Where N is the desired runlevel.
The runlevel can be set using kernel parameters. Edit
/etc/default/grub
, and change:to
Where N is the runlevel you want. Then run:
You can also force a one-time boot to a different runlevel by editing the command line from the GRUB menu at boot.
In practice, remember that runlevels 2-5 have no difference in the default Ubuntu setup. So don't expect anything different to happen if you boot to runlevel 3.