Assuming systemd treats
ttyAMA0 as a serial port the same way it would treat
ttyS0 on a PC, you need to edit the command started by the
(You could check if
systemctl status serial-getty@ttyAMA0 shows it is active.)
The base version is in
/lib/systemd/system/serial-getty@.service and inside it we find the command that starts the getty:
ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM
Create an override file for the service to start the
Create the directory
/etc/systemd/system/serial-getty@ttyAMA0.service.d, and a file called
override.conf in it with the following content:
ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,38400,9600 %I $TERM
systemctl edit serial-getty@ttyAMA0.service will help with doing this.
Note that the terminal type passed as an argument to
agetty needs to match what your serial terminal actually is. This has been the subject of various approaches in systemd over the years. It has variously been hardwired to
vt102 and (indirectly) inherited from the kernel/bootstrap loader. The current approach (as of 2020) is rather complex in how it makes its decision.
However, it only eventually picks from the three values
vt220, and whatever the kernel/bootstrap loader says for the Linux console. The first is never right for any real terminal, and unlikely to even approximately match a terminal emulator over a serial cable. The second is unlikely to be right, especially when it comes to colour. Neither matches PuTTY, whose correct terminal type is
putty-256color). And the third probably won't be
putty, either; unless you've redirected the Linux
/dev/console to the serial terminal and PuTTY as well, and properly reconfigured the boot loader with the console terminal type in lockstep.
So for best results you also need to set the
TERM environment variable in that override file:
Then reload systemd and we can check that the new configuration is in place:
# systemctl daemon-reload
# systemctl cat serial-getty\@ttyAMA0 | grep Exec
(we should see the new command on the last
If you want to only autologin after a key press, add
--login-pause to the
agetty command line.
The page you linked talks about configuring automatic login on a virtual console: they are configured through
getty@.service and the command line used for
agetty is a bit different (it seems to be just missing the
--keep-baud option). In that case we would use, say
There's an answer in Ask Ubuntu with more details about overriding systemd configuration.
On a system with sysvinit instead of systemd, you need to add/modify the line corresponding to the serial port in
T0:23:respawn:/sbin/getty -L ttyAMA0 --autologin root 38400 vt100