ArchLinux 2017.10.01: GRUB2 and Linux with serial console

This article will describe changing GRUB2 and Linux to serial console.

1 /etc/default/grub

Change /etc/default/grub as below.

  • Change GRUB terminal to console and serial. This will provide one GRUB to a monitor display and serial console.
  • Change linux kernel console to tty1 and ttyS0.
cat <<EOF | sudo tee /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200"
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
GRUB_DISABLE_LINUX_UUID=true
GRUB_DISABLE_RECOVERY=true
EOF

2 grub-mkconfig

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

$ sudo grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initramfs image: /boot/initramfs-linux-fallback.img
done

Reboot ArchLinux.

$ 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 display is as below.

0003_Linux-to-Display.png

Login prompt to serial console is as below.

0004_Linux-to-SerialConsole.png