Pages

November 14, 2016

Serial console in RHEL 7

This was tested on RHEL7.3


If you DONT WANT to make serial console as default console:


Enable getty on your serial port

# systemctl enable getty@ttyS0
Created symlink from /etc/systemd/system/getty.target.wants/getty@ttyS0.service to /usr/lib/systemd/system/getty@.service.

And reboot (or use systemctl start for same service)


If you WANT to make serial console as default console

Dont enable getty like in previous step! (you will have duplicate gettys running on serial port, and they will collide).

Modify /etc/sysconfig/grub to contain entries for your serial port (ttyS0 for in this example)

GRUB_TERMINAL_INPUT="serial console"
GRUB_TERMINAL_OUTPUT="serial console"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rhgb quiet console=tty0 console=ttyS0,9600"


Recreate grub file:


# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-5aa1bafc68ad4d229e06111f3ad495b3
Found initrd image: /boot/initramfs-0-rescue-5aa1bafc68ad4d229e06111f3ad495b3.img
done

After reboot, you can see getty running on serial port

# systemctl |grep ttyS0
sys-devices-pnp0-00:04-tty-ttyS0.device                                             loaded active plugged   /sys/devices/pnp0/00:04/tty/ttyS0
serial-getty@ttyS0.service                                                          loaded active running   Serial Getty on ttyS0


BTW, I recommend to delete words "rhgb quiet" from GRUB_CMDLINE_LINUX line in /etc/sysconfig/grub. It helps in various debugging sessions, but can sometimes create problem, if there is a LOT of output (in which case just leave it enabled - default).