2

What I want to accomplish

I would like to have remote terminal access to my NAS (which runs Debian Stretch) via an USB-RS232 adapter. As this machine is supposed to be headless, I would also like to see the boot process on the serial line.

(Still, for the sake of assessing this problem, there is a screen connected on the HDMI port at the moment.)

The actions I took

I appended console=ttyUSB0 to the kernel argument list. When booting, this causes my system to freeze.

The last lines of boot output are: (Bootloader is extlinux)

Loading /vmlinuz... ok
Loading /initrd.img...ok
Probing EDD (edd=off to disable)... ok

When not using said kernel parameter the machine is booting without problems. From there on, I could accomplish serial terminal access easily by running

systemctl enable serial-get[email protected]
systemctl start [email protected]

on the remote server, and

screen -F /dev/ttyUSB0 9600

on my local machine. Hence, the USB-RS232 adapters are working correctly. The server is a Intel NUC 5CPYH with Braswell chipset and runs a Linux 4.9.0-4-amd64 debian kernel.

My question

Which actions do I have to take to get it working?

Edit № 1

When providing console=tty0 console=ttyUSB0,9600n8 as boot parameters the machine boots just fine, but I still cannot connect to the serial port. Also, systemctl status [email protected] says that the service is loaded and inactive (dead). I would have expected it to be up and running then.

Edit № 2

I did a bit of research and found out that my initramfs was lacking the relevant kernel modules. I managed to enter the initramfs shell by providing break=init as kernel parameter and saw that there was no /dev/ttyUSB0 device.

I added cp210x, pl2303 and ftdi_sio to /etc/initramfs-tools/modules and, after recreating the initramfs, saw that now there is a /dev/ttyUSB0 device in initramfs shell.

Still, I couldn't connect from my other machine. So I tried to start getty on that device manually:

# /sbin/getty -L 9600 /dev/ttyUSB0 vt100
getty: setsid: Operation not permitted
# su root -c "/sbin/getty -L 9600 /dev/ttyUSB0 vt100"
sh: su: not found

So that's where I am now.

1
  • 2
    So sad to see motherboards without even a vestigial serial port these days. If you just want boot messages you might look at netconsole instead, to get them over the ethernet. Also, lots of articles say you need a kernel compiled with CONFIG_USB_SERIAL_CONSOLE=y to get boot messages on usb, and this is not often the case as it still marked "experimental".
    – meuh
    Feb 21, 2018 at 11:20

2 Answers 2

3

Your system is not freezing. You just directed ALL your output to the serial console.

Passing console arguments to the kernel, you have got to include both the local console and the serial interface.

See TLDP - Remote Serial Console HOWTO - Chapter 5. Configure Linux kernel

Figure 5-2. Recommended kernel parameters, PCs with video card

console=tty0 console=ttyS0,9600n8

Kernel messages will appear on both the first virtual terminal and the serial port. Messages from the init system and the system logger will appear only on the first serial port. This can be slightly confusing when looking at the attached monitor: the machine will appear to boot and then hang. Don't panic, the init system has started but is now printing messages to the serial port but is printing nothing to the screen. If a getty has been configured then a login: prompt will eventually appear on the attached monitor.

For PCs without a video card, this HOWTO suggests the kernel parameters:

Figure 5-3. Recommended kernel parameters, PCs without video card

console=ttyS0,9600n8

These parameters are passed to the booting kernel by the boot loader. Next we will configure the boot loader used by your Linux installation to pass the console parameters to the kernel.

3
  • Unfortunately this didn't work either. I edited my questions with the results of your suggestion. This was a very valid concern though, hence I upvoted your answer.
    – Multisync
    Feb 19, 2018 at 21:58
  • what did not work? When I setup this in kernel, I had also to start the service afterwards for serial to work. Feb 19, 2018 at 22:09
  • 1
    I could not see boot output on the other machine which was connected over the serial line. Also, the blog page of the systemd author suggests that starting the service manually should not be necessary when using the console boot parameter: TL;DR: To make use of a serial console, just use console=ttyS0 on the kernel command line, and systemd will automatically start a getty on it for you.
    – Multisync
    Feb 19, 2018 at 22:22
1

Debian currently does not build its Linux kernel with CONFIG_USB_SERIAL_CONSOLE=y, which is required for this feature to work.

The corresponding bug report is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868352

After building my own kernel with CONFIG_USB_SERIAL_CONSOLE=y (see https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s-common-official), I also had to include the FTDI serial driver for my adapter in the initrd:

# echo ftdi_sio >> /etc/initramfs-tools/modules
# update-initramfs -u

Finally, I adjusted /etc/default/grub to read:

GRUB_CMDLINE_LINUX_DEFAULT="panic=10 panic_on_oops=1 console=tty0 console=ttyUSB0,115200"

…and ran update-grub.

Afterwards, I successfully see the boot messages and can log in via the automatically starting serial-getty@ttyUSB0 service.

1
  • Unable to test, but sounds very reasonable. Plus, the author used to be involved in the Debian project. Thus, accepting it as correct answer for now.
    – Multisync
    Aug 1, 2021 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .