sudo cp -nv /etc/default/grub /etc/default/grub.orig
sudo cp -nv /boot/grub/grub.cfg /boot/grub/grub.cfg.orig
sudo vim /etc/default/grub
/etc/default/grub
:
## remove (optional):
# GRUB_TIMEOUT_STYLE=hidden
## change:
# (optional)
# GRUB_TIMEOUT=0
GRUB_TIMEOUT=2
## add:
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200"
## change:
# GRUB_CMDLINE_LINUX=""
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200"
If GRUB_TIMEOUT
is 1 or more (or -1), you can bring up the menu by pressing the Escape </ kbd> key even if GRUB_TIMEOUT_STYLE = hidden
([ref.](Https: /) /www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html)).
By adding GRUB_TERMINAL =" console serial "
, the GRUB menu will be displayed on both the VGA console and the serial terminal.
If you don't see the output of the serial console, see the Manual (https://www.gnu.org/software/grub/manual/grub/html_node/serial.html) for your hardware and GRUB_SERIAL_COMMAND = Try changing "serial --speed = 115200"
.
GRUB_CMDLINE_LINUX =" console = tty1 console = ttyS0,115200 "
is the Linux kernel command-line parameter )is. Similar to GRUB_TERMINAL =" console serial "
, this option allows tty input / output on both the VGA console (tty1) and the serial console (ttyS0).
This can also be changed in the GRUB menu at boot time.
After editing / etc / default / grub
, run sudo update-grub
to generate /boot/grub/grub.cfg
which is actually loaded at boot time. It internally runs grub-mkconfig -o /boot/grub/grub.cfg
.
Original (depending on the environment, this is from QEMU):
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
# 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=console
# 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=640x480
# 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
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
Revised:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
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=console
#GRUB_TERMINAL="console serial"
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200"
# 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=640x480
# 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
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
diff:
sudo apt install python3-pip
pip3 install icdiff
~/.local/bin/icdiff /etc/default/grub.orig /etc/default/grub
~/.local/bin/icdiff /boot/grub/grub.cfg.orig /boot/grub/grub.cfg
The diff of /boot/grub/grub.cfg
is large, so please check it with your own eyes.
After rebooting, dmesg will be played on the serial console and the login prompt will be displayed.
<img alt = "Creative Commons License" style = "border-width: 0" src = "https" //i.creativecommons.org/l/by/4.0/88x31.png "/>
This work is Creative Commons Attribution 4.0 International Licenses .
Recommended Posts