Wednesday, November 13, 2019

Configure Console Only Login On Ubuntu 16.04+ Desktop

Occasionally we may want to login to our Ubuntu Desktop as console only mode (for eg: running our Ubuntu desktop as a bare metal hypervisor, only to launch Virtual Machines which will be connected remotely).

This will help to run the desktop with bare minimum memory (120MB RAM on Ubuntu 16.04) and CPU usage.

By default Ubuntu Desktop 16.04+ does not provide (which has Systemd than the legacy init system) this option, and you’ve to configure the same. Once configured you will get a new Grub menu entry on startup, to login as Console Mode.

  1. Copy a sample menu entry from (/boot/grub/grub.cfg) to (/etc/grub.d/40_custom)

    Sample:

    menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0e341ce4-5a12-4a6d-a997-5336d1670353' {

           recordfail

           load_video

           gfxmode $linux_gfx_mode

           insmod gzio

           if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi

           insmod part_msdos

           insmod ext2

           set root='hd2,msdos5'

           if [ x$feature_platform_search_hint = xy ]; then

             search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos5 --hint-efi=hd2,msdos5 --hint-baremetal=ahci2,msdos5  0e341ce4-5a12-4a6d-a997-5336d1670353

           else

             search --no-floppy --fs-uuid --set=root 0e341ce4-5a12-4a6d-a997-5336d1670353

           fi

            linux /boot/vmlinuz-4.15.0-54-generic root=UUID=0e341ce4-5a12-4a6d-a997-5336d1670353 ro  ipv6.disable=1  scsi_mod.use_blk_mq=1

           initrd /boot/initrd.img-4.15.0-54-generic

    }

     

  2. Update the copied entry as per below (highlighted text). The crux is ‘systemd.unit’ property.

    Sample:

    menuentry 'Ubuntu-TextMode' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0e341ce4-5a12-4a6d-a997-5336d1670353' {

           recordfail

           #load_video

           #gfxmode $linux_gfx_mode

           insmod gzio

           if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi

           insmod part_msdos

           insmod ext2

           set root='hd2,msdos5'

           if [ x$feature_platform_search_hint = xy ]; then

             search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos5 --hint-efi=hd2,msdos5 --hint-baremetal=ahci2,msdos5  0e341ce4-5a12-4a6d-a997-5336d1670353

           else

             search --no-floppy --fs-uuid --set=root 0e341ce4-5a12-4a6d-a997-5336d1670353

           fi

            linux /vmlinuz root=UUID=0e341ce4-5a12-4a6d-a997-5336d1670353 systemd.unit=multi-user.target ro  ipv6.disable=1  scsi_mod.use_blk_mq=1

           initrd /initrd.img

    }


  3. Update grub using (Sudo update-grub2)

  4. Reboot

  5. Select the menu entry “Ubuntu-TextMode’