Serial Getty error messages

agettygetty

I've a cloud server, with CentOS distribution, and an Apache instance to manage some web apps, like WordPress or PrestaShop.

I noticed that an error is reported in log files (var/log/).

  • In particular in messages:
    May 30 11:54:41 xxx00962 systemd: Starting Serial Getty on ttyS0...
    May 30 11:54:41 xxx00962 systemd: Started Serial Getty on ttyS0.
    May 30 11:54:51 xxx00962 systemd: serial-getty@ttyS0.service holdoff time over, scheduling restart.
    May 30 11:54:51 xxx00962 systemd: Stopping Serial Getty on ttyS0...
    
  • and in secure:
    May 30 15:51:30 xxx00962 agetty[24693]: /dev/ttyS0: not a character device
    

where xxx00962 is the (anonymized) hostname.

I don't know what is getty for, but I'd like to solve the problem.

Someone can help me and explain how getty works?

Best Answer

getty is one of the oldest Unix programs. You are using a workalike program written by Wietse Venema, agetty, that was written when getty was around twenty years old.

This program is being run because your system thinks that you have a terminal attached to a serial device, with the character device filename /dev/ttyS0. When your system bootstrapped, a program named systemd-getty-generator saw ttyS0 in /sys/class/tty/console/active, because of it being listed after a console= in the kernel command line. The generator caused the serial-getty@.service template service unit to be instantiated as serial-getty@ttyS0.service; and this is the service whose attempted activations you are seeing being logged.

The service provides terminal log-on via that device.

For some reason (presuming that you have a version of systemd from 2014 or later), your system is inconsistent, and now believes that /dev/ttyS0 is not a character device file, let alone a character device that is a terminal. systemd-getty-generator thought that it was at bootstrap. There are at least two ways in which it could have changed. Which, if either, has occurred cannot be determined from your question.

Fix /dev/ttyS0.

  • If it is supposed to be a character device but isn't, then find out what is changing it at runtime.
  • If it is not supposed to be a character device, find out why it was a terminal device at bootstrap when systemd-getty-generator checked it. Also stop telling the kernel on its command line that it is the console. If it is not supposed to be a character device, because you do not have a serial port (with terminal attached or without), then telling the kernel that a non-existent serial port is the console is simply wrong.
  • If it is supposed to be a character device that is a terminal, but you do not want to be able to log on from that terminal, stop telling the kernel on its command line that it is the console.
  • If it is supposed to be a character device that is a terminal, but you want it to be the kernel console but still do not want to be able to log on from that terminal (or indeed other any other non-virtual-terminal consoles), disable systemd-getty-generator because its primary functionality is not what you want.

Further reading

Related Question