#1615 PR merged: Solved issue #878 (Can't see login prompt on serial console)

Labels: enhancement, fixed / solved / done

didacog opened issue at 2017-12-01 14:58:

The problem is with systemd regarding recovery image console and serial-console.

These changes worked in our tests with RHEL7.2 on HP supoerdomeX hardware with ILO console and serial console, with Debian 9 and Centos7 on libvirt with and without serial port attached:

usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service

#  This file is part of systemd.
#

[Unit]
Description=Getty on %I
Documentation=man:agetty(8)
After=systemd-user-sessions.service plymouth-quit-wait.service
After=sysinit.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# On systems without virtual consoles, don't start any getty. (Note
# that serial gettys are covered by serial-getty@.service, not this
# unit
#ConditionPathExists=/dev/tty0

[Service]
Environment=TERM=linux
ExecStart=-/sbin/agetty %I 38400
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

# Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly.
KillSignal=SIGHUP

[Install]
WantedBy=getty.target
DefaultInstance=tty0

usr/share/rear/skel/default/usr/lib/systemd/system/serial-getty@.service

#  This file is part of systemd.
#
[Unit]
Description=Serial Getty on %I
BindTo=dev-%i.device
After=dev-%i.device

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target

[Service]
Environment=TERM=vt100
ExecStart=-/sbin/agetty -s %I 115200,38400,9600
Restart=always
RestartSec=0
UtmpIdentifier=%I
KillMode=process

# Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly.
KillSignal=SIGHUP

[Install]
WantedBy=getty.target

IN usr/share/rear/skel/default/usr/lib/systemd/system/getty.target.wants/

rm getty@tty{1,2,3,4}.service
ln -s ../getty@.service getty@tty0.service
ln -s ../serial-getty@.service serial-getty@ttyS0.service

Regards,
Didac

jsmeix commented at 2017-12-02 12:21:

According to https://github.com/rear/rear/issues/878#issuecomment-346929895
this pull request belongs to ReaR 2.3

gdha commented at 2017-12-12 07:42:

@didacog This PR breaks recovery on ubuntu16 (virtualbox without serial console). It kept on respawning and I had to interrupt to login, therefore, auto-recover failed:

RESCUE client:~ # dmesg | grep agetty | wc -l
399
RESCUE client:~ # dmesg | grep agetty | tail 
[ 2284.970314] systemd[1]: Received SIGCHLD from PID 4451 (agetty).
[ 2284.970342] systemd[1]: Child 4451 (agetty) died (code=exited, status=1/FAILURE)
[ 2284.982304] systemd[1]: serial-getty@ttyS0.service: About to execute: /sbin/agetty -s ttyS0 115200,38400,9600
[ 2284.982516] systemd[1]: serial-getty@ttyS0.service: Forked /sbin/agetty as 4530
[ 2284.984704] systemd[4530]: serial-getty@ttyS0.service: Executing: /sbin/agetty -s ttyS0 115200,38400,9600
[ 2294.986119] systemd[1]: Received SIGCHLD from PID 4530 (agetty).
[ 2294.986129] systemd[1]: Child 4530 (agetty) died (code=exited, status=1/FAILURE)
[ 2294.987733] systemd[1]: serial-getty@ttyS0.service: About to execute: /sbin/agetty -s ttyS0 115200,38400,9600
[ 2294.987810] systemd[1]: serial-getty@ttyS0.service: Forked /sbin/agetty as 4604
[ 2294.988244] systemd[4604]: serial-getty@ttyS0.service: Executing: /sbin/agetty -s ttyS0 115200,38400,9600

didacog commented at 2017-12-12 08:02:

@ghda Let me check this, because we tested it on debian sucessfully. I'll update with the results.

Thanks!

gdha commented at 2017-12-12 12:50:

@didacog perhaps some interesting lines from the journalctl (ubuntu 16.04):

Dec 12 07:59:07 client agetty[14180]: /dev/ttyS0: not a tty
Dec 12 07:59:07 client systemd[1]: serial-getty@ttyS0.service: Forked /sbin/agetty as 14180
Dec 12 07:59:07 client systemd[1]: serial-getty@ttyS0.service: Changed dead -> running
Dec 12 07:59:07 client systemd[1]: serial-getty@ttyS0.service: Job serial-getty@ttyS0.service/start finished, result=done
Dec 12 07:59:07 client systemd[1]: Started Serial Getty on ttyS0.
Dec 12 07:59:07 client systemd[14180]: serial-getty@ttyS0.service: Executing: /sbin/agetty -s ttyS0 115200,38400,9600
Dec 12 07:59:07 client systemd[1]: Accepted new private connection.
Dec 12 07:59:07 client systemd[1]: Got message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1/agent interfacDec 12 07:59:07 client systemd[1]: Got disconnect on private connection.
Dec 12 07:59:07 client systemd[1]: Got disconnect on private connection.
Dec 12 07:59:17 client systemd[1]: Received SIGCHLD from PID 14180 (agetty).
Dec 12 07:59:17 client systemd[1]: Child 14180 (agetty) died (code=exited, status=1/FAILURE)
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Child 14180 belongs to serial-getty@ttyS0.service
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Main process exited, code=exited, status=1/FAILURE
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Changed running -> dead
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Changed dead -> auto-restart
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: cgroup is empty
Dec 12 07:59:17 client systemd[1]: Accepted new private connection.
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Service has no hold-off time, scheduling restart.
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Trying to enqueue job serial-getty@ttyS0.service/restart/fail
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Installed new job serial-getty@ttyS0.service/restart as 2927
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Enqueued job serial-getty@ttyS0.service/restart as 2927
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Scheduled restart job.
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Changed auto-restart -> dead
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Job serial-getty@ttyS0.service/restart finished, result=done
Dec 12 07:59:17 client systemd[1]: Stopped Serial Getty on ttyS0.
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Converting job serial-getty@ttyS0.service/restart -> serial-getty@ttySDec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: About to execute: /sbin/agetty -s ttyS0 115200,38400,9600
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Forked /sbin/agetty as 14183
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Changed dead -> running
Dec 12 07:59:17 client systemd[1]: serial-getty@ttyS0.service: Job serial-getty@ttyS0.service/start finished, result=done
Dec 12 07:59:17 client systemd[1]: Started Serial Getty on ttyS0.
Dec 12 07:59:17 client agetty[14183]: /dev/ttyS0: not a tty

And then, everything repeats over and over again.


[Export of Github issue for rear/rear.]