We've been talking about cloud servers too much in recent years. How many of you remember the famous COM1, COM2 ports from old times? In this post, we are streaming console to serial ports again to access console from cloud providers.

On Linux

We just have to add this parameter to linux command line to redirect console to primary serial port ttyS0.

console=ttyS0,115200n8

We can add this parameter using GRUB, on boot (Ctrl-X) or permanently.

Edit /etc/default/grub. Example config from CentOS 9 Stream:

GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

Don't forget grub make config:

grub2-mkconfig -o /boot/grub2/grub.cfg

https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html

On FreeBSD

I just want to share this shell script about. Please review changed files after.

echo 'console="comconsole"' >> /boot/loader.conf
echo '-h' >> /boot.config
echo 'console "/usr/libexec/getty Pc" cons25 on secure' >>/etc/ttys