Serial console short HowTo

As I always forget the steps to bring a serial console “online” for all boot steps, here’s a try to summarize…

Assumptions:

  • Serial device is /dev/ttyS0
  • Port speed is 115200
  • no parity
  • 8 data bits

In the end you should be able to follow your system from the boot menu of your grub bootloader until the login prompt. The only steps missing are the ones you need to do in the BIOS of your mainboard – just refer to the BIOS manual (and keep in mind that a “redirect after POST” is not needed any more with this guideline below).

1a. for grub version 0-1: File /boot/grub/menu.lst

serial --unit=0 --speed=115200
terminal --timeout=2 serial console
[...]
title [...]
    kernel /boot/vmlinuz [...] console=tty0 console=ttyS0,115200n8

1b. for grub version >=2: File /etc/default/grub

GRUB_CMDLINE_LINUX='console=tty0 console=ttyS0,115200n8'
GRUB_TERMINAL="console serial"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

Note: Please uncomment all other lines with the same syntax.

And do not forget to re-generate the menu of grub2:
grub2-mkconfig -o /boot/grub2/grub.cfg

2. File /etc/inittab

[...]
S0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt102
[...]

3. File /etc/securetty

[...]
ttyS0
[...]

4. File /etc/sysconfig/bootloader

[...]
DEFAULT_APPEND="[...] console=tty0 console=ttyS0,115200n8"
[...]
FAILSAFE_APPEND="[...] console=tty0 console=ttyS0,115200n8"
[...]

If you want to test directly in the running system, please do not forget to call init q after doing the changes. ps ax | grep tty should print out something like:

7429 ttyS0    Ss+    0:00 /sbin/agetty -L 115200 ttyS0 vt102

5. Special behavior for systemd

If you are running systemd and want to have the settings above always loaded during boot, please do the following:
cp {,usr}/lib/systemd/system/getty\@.service /etc/systemd/system/getty.target.wants/getty\@ttyS0.service
and adapt the file /etc/systemd/system/getty.target.wants/getty@ttyS0.service with your favorite editor:

...
[Service]
ExecStart=-/sbin/agetty %I 115200
...
[Install]
Alias=getty.target.wants/getty@ttyS0.service

Again, if you want to test directly in the running system, please proceed with the following commands (“init q” does not work here):
systemctl –system daemon-reload
systemctl start getty@ttyS0.service

Now you should connect a serial cable between your host and another machine and start screen /dev/ttyS0 115200 there. After pressing the [ENTER] key, you should see the login prompt of your machine.

Advertisements

About Lars Vogdt

This is the private blog space of Lars Vogdt, the topics will be in first place work related.
This entry was posted in openSUSE, SUSE Linux Enterprise and tagged , , , . Bookmark the permalink.

One Response to Serial console short HowTo

  1. Pingback: Datacenter in a box | lvogdt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s