從Systemd(Systemctl)設置:

$ cp /usr/lib/systemd/system/serial-getty@.service /etc/systemd/system/serial-getty@ttyS0.service
$ vi /etc/systemd/system/serial-getty@ttyS0.service
//# Modify "ExecStart" line as below.
//# E.g.: Rate=57600, 
>> ExecStart=-/sbin/agetty 57600 %I $TERM
//# E.g.: Rate=115200, 
>> ExecStart=-/sbin/agetty 115200 %I $TERM 
//# E.g.: Rate=115200, 
>> ExecStart=-/sbin/agetty 115200 %I $TERM 
//# E.g.: Rate=115200, 
>> ExecStart=-/sbin/agetty -o '-p -- \\u' 115200 %I $TERM
//# Recommend remove "--keep-baud" that if you expect it take effect immediately.(Mean without reboot or others operation.)
$ systemctl daemon-reload
//# For a built in serial port /dev/ttyS0
$ systemctl enable --now serial-getty@ttyS0.service
$ systemctl status serial-getty@ttyS0.service

 

從GRUB設置( E.g.:RHEL/CentOS EL7以後 或 Ubuntu)

//# Modify "/etc/default/grub" file and add "console=tty0 console=ttyS0,115200n8" in "GRUB_CMDLINE_LINUX" line.
$ vi /etc/default/grub
//# Before modify: GRUB_CMDLINE_LINUX=""
>> GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
//# Keep original parameters, just add 'console=tty0 console=ttyS0,115200n8'.

//# (Not necessary) From some information on Internet, it will also add "serial --unit=1 --speed=115200 --word=8 --parity=no --stop=1" in "GRUB_SERIAL_COMMAND" line. 
$ vi /etc/default/grub
//# Add: 'serial --unit=1 --speed=115200 --word=8 --parity=no --stop=1'
>> GRUB_SERIAL_COMMAND="serial --unit=1 --speed=115200 --word=8 --parity=no --stop=1"

//# If under OS contain file: /etc/securetty
>> insert ttyS0

//# Update GRUB
//# If OS: Ubuntu. Update grub.cfg:
$ grub-mkconfig -o /boot/grub/grub.cfg"
//# If OS: RHEL/CentOS/ Enterprise Linux series(EL x) OS.
//$ Update grub.cfg for Legacy OS:
$ grub2-mkconfig -o /boot/grub2/grub.cfg
//# Update grub.cfg for UEFI BIOS:          
$ grub2-mkconfig -o /boot/efi/EFI/xxxxx/grub.cfg"
//# If RHEL OS, xxxxx=redhat. If CentOS, xxxxxx=centos , ...etc "
 

兩者的差異是:
1. 從Systemd(Systemctl) 啟用:OS開機至user login才會將文字訊息會顯示在Serial上 
意思是 BIOS開機脫離BIOS POST到Linux login之間的任何階段,Serial的畫面都不會有文字顯示出來
E.g. Server BIOS: 
Configuring firmware is in progress...                                          
Importing firmware configuration settings from OData server.                    
Wait for BMC to update Inventory data > \
Ubuntu 22.04 LTS localhost ttyS0
 

2. 從GRUB 啟用:開機過程/關機過程的文字訊息會顯示在Serial上 
E.g. Server BIOS: 
Configuring firmware is in progress...                                          
Importing firmware configuration settings from OData server.                    
Wait for BMC to update Inventory data > \
(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OS 啟用過程的訊息 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OS 啟用過程的訊息 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OS 啟用過程的訊息 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OS 啟用過程的訊息 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
Ubuntu 22.04 LTS localhost ttyS0

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 吾給力 的頭像
    吾給力

    吾給力的部落格

    吾給力 發表在 痞客邦 留言(0) 人氣()