1

I am running the latest Kubuntu (14.10) and would like to add a grub2 menu entry that allows me to boot straight into a different runlevel? I would like to modify /etc/rc3.d or /etc/rc4.d to boot straight into the command line and not load X. I believe the custom menu entry should be placed in /etc/grub.d/40_custom? I assume I can copy my/the default menu entry in /boot/grub/grub.cfg? but then how do i make this entry boot at a different runlevel?

Can I add the command telinit 3 to the end of the custom menu entry?

any help would be appreciated :)

0

1 Answer 1

5

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: entry
The contents of that entry: contents

Of course, normally runlevels 2-5 are equivalent, so booting from it made no difference to me, except:

$ runlevel
N 3
8
  • I have just tried this and it works very well :) Thank You @muru Now I am going to do a backup then try modifying '/etc/rc3.d' and remove 'lightdm'
    – sinttx
    Commented Oct 7, 2014 at 2:33
  • @sinttx Since upstart handles these things now, you should probably be looking at /etc/init/lightdm.conf.
    – muru
    Commented Oct 7, 2014 at 2:45
  • I might have been working from outdated information :( I will do some research into '/etc/init/lightdm.conf' as described. Thanks again @muru
    – sinttx
    Commented Oct 7, 2014 at 2:58
  • I have managed to achieve this by updating the 10-linux file. Has anyone worked out how /etc/init/lightdm.conf is meant to be used to achieve the same thing (i.e. alternative to start in console only without X)?
    – Batwam
    Commented Jan 6, 2022 at 15:45
  • @hyg53 typiclly you just disable lightdm if you don't want it to start (e.g., systemctl disable lightdm.service, since these days its systemd and not Upstart)
    – muru
    Commented Jan 7, 2022 at 4:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .