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.
- Remove hidden parameter for avoiding "no video mode activated" error. And change GRUB timeout from 8 seconds to 1 second.
- 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.
> diff -uprN /etc/default/grub{.org,}
--- /etc/default/grub.org 2016-11-18 20:36:48.028609459 +0900
+++ /etc/default/grub 2016-11-18 20:40:57.438040576 +0900
@@ -6,23 +6,21 @@
# /boot/grub2/grub.cfg.
GRUB_DISTRIBUTOR=openSUSE
GRUB_DEFAULT=saved
-GRUB_HIDDEN_TIMEOUT=0
-GRUB_HIDDEN_TIMEOUT_QUIET=true
-GRUB_TIMEOUT=8
-GRUB_CMDLINE_LINUX_DEFAULT=" resume=/dev/system/swap splash=silent quiet showopts"
+GRUB_TIMEOUT=1
+GRUB_CMDLINE_LINUX_DEFAULT=" resume=/dev/system/swap splash=silent showopts"
# kernel command line options for failsafe mode
GRUB_CMDLINE_LINUX_RECOVERY="showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe"
-GRUB_CMDLINE_LINUX=""
+GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
-GRUB_TERMINAL=gfxterm
+GRUB_TERMINAL="console serial"
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
-GRUB_GFXMODE=auto
+#GRUB_GFXMODE=auto
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
2 grub2-mkconfig
Update grub.cfg with grub2-mkconfig.
> sudo grub2-mkconfig -o /boot/grub2/grub.cfg
You can operate GRUB and Linux via serial console. You can also operate these via tty1.