Fedora 27: GRUB2 and Linux with serial console

This article will describe changing GRUB2 and Linux to serial console. This is not for desktop environment but embedded system and virtual machine environment.

1 /etc/default/grub

Change /etc/default/grub as below.

  • Change GRUB terminal to console and ttyS0. This will provide one GRUB to a monitor display and serial console.
  • Change linux kernel console to tty1 and ttyS0. This setting will be taken over to userland, and there will be two login prompt for tty1 and ttyS0.
$ cat /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR=$(sed "s, release .*$,,g" /etc/system-release)
GRUB_DISABLE_SUBMENU=true
GRUB_CMDLINE_LINUX="rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap"
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200"
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
GRUB_DISABLE_RECOVERY="true"

2 grub2-mkconfig

Update /boot/grub2/grub.cfg with grub2-mkconfig.

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.13.9-300.fc27.x86_64
Found initrd image: /boot/initramfs-4.13.9-300.fc27.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-55e8571f1d954b0d81bcf12ff2fd4c64
Found initrd image: /boot/initramfs-0-rescue-55e8571f1d954b0d81bcf12ff2fd4c64.img
done

Reboot system.

$ sudo reboot

3 Execution result

GRUB to monitor display is as below.

0001_GRUB-to-Display.png

GRUB to serial console is as below. This article used "sudo virsh console <vmname>" for connecting serial console.

0002_GRUB-to-SerialConsole.png

Login prompt to monitor display is as below. tty1 is displayed with press Ctrl + Alt + F1.

0003_Linux-to-Display.png

Login prompt to serial console is as below.

0004_Linux-to-SerialConsole.png