[LINUX] Using a serial console on Ubuntu 20.04

serial console

English

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"

Description
If you delete `GRUB_TIMEOUT_STYLE = hidden` and set` GRUB_TIMEOUT = 2`, the GRUB menu will be displayed at boot time.

GRUB menu

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.

GRUB menu in both VGA console and 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).

tty output on both tty1 and ttyS0

This can also be changed in the GRUB menu at boot time.

Modify command-line parameter in GRUB menu


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.


/ etc / default / grub original, modified, diff

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

diff /etc/default/grub

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

Using a serial console on Ubuntu 20.04
Set up a file server on Ubuntu 20.04 using Samba
Building a Python environment on Ubuntu
Introducing Python using pyenv on Ubuntu 20.04
Run Yocto on Ubuntu using QEMU.
Until building a Python development environment using pyenv on Ubuntu 20.04
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Shebang on Ubuntu 20.04
CPU usage is 100% when using pygame on Ubuntu 16.04
A addictive story when using tensorflow on Android
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Try using a QR code on a Raspberry Pi
Python development on Ubuntu on AWS EC2 (using JupyterLab)
[Venv] Create a python virtual environment on Ubuntu
Build a Kubernetes environment for development on Ubuntu
Notes for using TensorFlow on Bash on Ubuntu on Windows
Connect to a serial console via Bluetooth (CentOS 7)
Create a GUI on the terminal using curses
Install TensorFlow on Ubuntu
Build a machine learning environment using PyCharm on Ubuntu environment (TensorFlow will also be introduced!)
Build a Django development environment using pyenv-virtualenv on Mac
Install PySide2 on Ubuntu
I got a UnicodeDecodeError when pip install on ubuntu
I made a Python3 environment on Ubuntu with direnv.
Install JModelica on Ubuntu
SoC FPGA: A small story when using on Linux
Build a Python environment on your Mac using pyenv
Troublesome story when using Python3 with VScode on ubuntu
Build a Python development environment using pyenv on MacOS
build Python on Ubuntu
Install Python 3.3 on Ubuntu 12.04
Installing pyenv on ubuntu 16.04
Install Theano on Ubuntu 12.04
A swampy story when using firebase on AWS lamda
Install angr on Ubuntu 18.04
Notes on using Alembic
Install pip / pip3 on Ubuntu
How to use Fujifilm X-T3 as a webcam on Ubuntu 20.04
I installed Ubuntu on a USB stick on a dual boot PC
How to build a new python virtual environment on Ubuntu
SSH connection to a private server using a bastion server on EC2
Building a Jupyter Lab development environment on WSL2 using Anaconda3
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
[Treasure Data] [Python] Execute a query on Treasure Data using TD Client
I made a VGG16 model using TensorFlow (on the way)
Install Linux (CentOS) on your PC using a USB stick
Don't ask for SSH passphrases using keychain on Ubuntu (linux)
Using X11 with ubuntu18.04 (C)
Set up Python 3.4 on Ubuntu
I installed tensorRT on Ubuntu 18.04
Run Jupyter on Ubuntu on Windows
Use matplotlib on Ubuntu 12 & Python
SoftwareRAID 0 on SereneLinux (Ubuntu 18.04 Desktop)
A comment on Boruta algorithm
Time measurement using a clock
I installed ROS on Ubuntu 18.04
USB Wifi on Ubuntu 20.04LTS
Set matplotlib font on ubuntu
Try using OpenCV on Windows
I want to automatically operate Chrome on Windows from a virtual machine (ubuntu) started using Vagrant
Put Python 3.x on Ubuntu