Nota: a resposta agrega poucas soluções de vários sites; no momento não tenho como testá-los.
SysVinit
Pre- systemd Linux pode usar /etc/inittab do sysvinit para gerar getty em vários terminais. A linha de exemplo pode se parecer com isso (tirada de este antigo guia ):
s0:2345:respawn:/sbin/getty -L 115200 ttyS0 vt102
Upstart
Se o seu sistema operacional usa upstart , o procedimento é diferente. Por exemplo. existe este howto :
Create a file called
/etc/init/ttyS0.confcontaining the following:# ttyS0 - getty # # This service maintains a getty on ttyS0 from the point the system is # started until it is shut down again. start on stopped rc RUNLEVEL=[12345] stop on runlevel [!12345] respawn exec /sbin/getty -L 115200 ttyS0 vt102Ask
upstartto start thegettysudo start ttyS0
Systemd
De acordo com este site , uma solução systemd pode ser tão simples quanto
To make use of a serial console, just use
console=ttyS0on the kernel command line, andsystemdwill automatically start agettyon it for you.
Você provavelmente configuraria seu GRUB2 para fazer isso. Analise o que Arch Wiki diz e ajuste sua distribuição, se necessário:
To make grub enable the serial console, open
/etc/default/grubin an editor. Change theGRUB_CMDLINE_DEFAULTline to start the console on/dev/ttyS0. Note in the example below, we set two consoles up; one ontty0and one on the serial port.GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,38400n8"Now we need to tell grub where is the console and what command to start in order to enable the serial console (Note as above for Linux kernel, one can append multiple input/output terminals in grub e.g.
GRUB_TERMINAL="console serial"would enable both display and serial):## Serial console GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"Rebuild the
grub.cfgfile with following command:grub-mkconfig -o /boot/grub/grub.cfgAfter a reboot,
gettywill be listening on/dev/ttyS0, expecting38400baud,8data bits, no parity and one stop bit. When Arch boots,systemdwill automatically start agettysession to listen on the same device with the same settings.
Ambos os sites concordam que, se você não quiser que o GRUB2 ouça no dispositivo serial, mas deseje apenas getty de escuta após o boot, então você precisará de algo como
systemctl enable [email protected]
systemctl start [email protected]
Sob demanda
Em caso de qualquer problema, lembre-se de que getty é apenas um programa, pode ser executado sob demanda ou de rc.local . Consulte man getty para detalhes. Eu acho que sua primeira tentativa pode ser como
sudo getty -L 115200 ttyS0 vt102
(Edit) Este é o feedback do OP, pode ajudar os usuários com problemas semelhantes:
I had to do
sudo su -c "…"for it to work properly.