This article will describe changing GRUB2 and Linux to serial console. This is not for desktop environment but embedded system and virtual machine environment.
Table of Contents
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.
#!/bin/sh -e # shellcheck disable=SC1091 . /etc/default/grub sudo cp /etc/default/grub /etc/default/grub.orig cat <<EOF | sudo tee /etc/default/grub GRUB_TIMEOUT=1 GRUB_DISTRIBUTOR="\$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL="console serial" GRUB_CMDLINE_LINUX=\ "$(echo "${GRUB_CMDLINE_LINUX}" | sed -e 's; rhgb quiet;;g')" GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,115200" GRUB_SERIAL_COMMAND=\ "serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1" GRUB_DISABLE_RECOVERY="true" GRUB_ENABLE_BLSCFG=true EOF sudo grub2-mkconfig -o /boot/grub2/grub.cfg sudo reboot