2017年7月8日 星期六

linux serial port console

serial port 是很古老的硬體, 但現在一堆機器 console 開始走回 serial port console 的老路, 不管是從以前到現在都有的 network manager machine 還 UEFI BIOS, 也就是說, 要跟的上時代, 就是找回過去 serial port console 的使用方法, 雖然聽起來有點古怪.

修改 grub2 部份, /etc/default/grub
grub2:
#grub terminal. --unit=0 意思就是 COM1, 往後類推.
GRUB_TERMINAL="serial vga_text gfxterm"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=1 --word=8 --parity=no --stop=1"

#kernel parameter
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS1,115200n8 splash"

grub2 部份使用 update-grub 去 update grub, 順路檢查語法正不正確. 在 update kernel 時也會順路補上這些參數, 不需要去 /boot/grub/grub.conf 裡再改一次.

ubuntu linux 16.04: (或任何使用 systemd 的 distro. 這裡假設為 ttyS0)
# systemctl enable serial-getty@ttyS0.service
特別注意這行, 因為每臺機器都會有點不同, 要用它設定的路徑才會有效.
Created symlink from /etc/systemd/system/getty.target.wants/getty@ttyS0.service
# mkdir -p /etc/systemd/system/getty.target.wants/getty@ttyS0.service.d/
# pico /etc/systemd/system/getty.target.wants/getty@ttyS0.service.d/override.conf
---
[Service]
ExecStart=
ExecStart=-/sbin/agetty --noissue --autologin myusername %I $TERM
Type=idle
---
myusername 就是你的預設使用者名稱, 也可以是 root.
目前已知在 i386, AMD64 distro 版本上要另外打開, 但 arm64 / armhf 似乎會看 /proc/cmdline 裡有沒有特別指定 console serial port 另外叫 systemd 打開 serial-port getty serrvice, 並不需要特別 enable 它. 也就所以要特別在 systemctl 裡特別去看它叫啥名字, 否則自動登入功能無法連動.

使用 sysinitV 的部份下次再補上.

沒有留言: