3

For Virtual Machines I create, as well as on old computers I use, I'd like to turn off gdm/lightdm in order to get better performance. I don't like to boot into single user mode ("linux single") because using root is a bad practice, and I also prefer to keep an easy way to boot back into graphic mode, so when graphic mode is required, no extra commands would be needed.

The way I see as the most useful is to configure Grub to show a menu item for "Ubuntu Text mode" in addition to the regular boot and the recovery mode, and set the text mode as default. I tried to do it myself, but Grub2 configuration files on /etc/grub.d/ looks too cryptic to me, and /etc/defaults/grub can set booting into text but it doesn't seems to allow keeping a menu item for graphical booting as well as setting text or graphics as default, and I prefer to keep the booting process simple to novice users so they won't need to mess with starting services manually or editing the kernel boot command line in Grub2.

Similar threads: https://askubuntu.com/a/196613/19967, https://askubuntu.com/a/79682/19967 - completely remove GUI and start it from the command line instead of Grub2 menuitems.

2 Answers2

5

A easy way to achieve what you want is editing the file /etc/grub.d/40_custom and create there a manual entry:

menuentry 'Ubuntu (Text mode)' --class ubuntu {
    recordfail
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    linux   /vmlinuz root=/dev/sda1 ro   text
    initrd  /initrd.img
}

of course, you need to replace sda1 and msdos1 with the correct partition (or UUID if you prefer).

After that run sudo update-grub and the new entry should be added at the end of the list.

This only creates a manual entry. If you want a automatic entry for each kernel then you must edit /etc/grub.d/10_linux.

Salem
  • 19,744
  • How can I create the automatic entries in 10_linux? – Tomer Cohen Nov 09 '12 at 21:34
  • You need to understand how that script is executed and modify it to, when it creates an entry for each kernel, add another entry similar with a different label and replacing quiet splash with text. If you want to try this, make a backup of the file before! I would recommend you to not modify it unless you really need to. – Salem Nov 09 '12 at 21:41
0

You need to add an entry to /etc/grub.d/40_custom

Become root

Open the file /boot/grub/grub.cfg

Copy the section that looks similar to what I paste into the /etc/grub.d/40_custom

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-7942e83c-f00f-4c7f-9ba6-cccf2284747c' {
recordfail
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  b8763e17-749f-4d80-b78e-276a3c8c75ef
    else
      search --no-floppy --fs-uuid --set=root b8763e17-749f-4d80-b78e-276a3c8c75ef
    fi
    linux   /vmlinuz-3.6.0-999-i7 root=UUID=7942e83c-f00f-4c7f-9ba6-cccf2284747c ro   crashkernel=384M-2G:64M,2G-:128M quiet splash $vt_handoff
    initrd  /initrd.img-3.6.0-999-i7
}

The above section is located in the section marked

### BEGIN /etc/grub.d/10_linux ###

Change the text quiet splash $vt_handoff to quiet splash text

Run: grub-mkconfig -o /boot/grub/grub.cfg

That should be it.