May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

CentOS / RHEL 7 : How to configure serial getty with systemd

With SysV init, by default, getty processes are started on the first six virtual consoles. They can be accessed with the Ctrl+Alt+F1 to Ctrl+Alt+F6 key combination. systemd starts the getty processes only when needed. That means, only after you change to, for instance, the second virtual terminal by pressing Ctrl+Alt+F2 is the getty process started in that terminal.

The /usr/lib/systemd/system/getty@.service file is responsible for the virtual terminals (/dev/tty[X]). /usr/lib/systemd/system/serial-getty@.service is responsible for all other terminals, such as a serial terminal on /dev/ttyS0.

Systemd provides a template unit file for serial getty. Template file can be found here

/lib/systemd/system/serial-getty@.service
Steps

1. First copy the template:

# cp /usr/lib/systemd/system/serial-getty@.service /etc/systemd/system/serial-getty@ttyS0.service
2. Then edit the file and modify the agetty line:

[Service]
ExecStart=-/sbin/agetty –keep-baud 115200,38400,9600 %I $TERM <-- Change this parameter Type=idle 3. Create a symlink: # ln -s /etc/systemd/system/serial-getty@ttyS0.service /etc/systemd/system/getty.target.wants/ 4. Reload the daemon and start the service: # systemctl daemon-reload # systemctl start serial-getty@ttyS0.service # systemctl enable serial-getty@ttyS0.service

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>