Debian 13 serial installer

Debian 13 serial installer

Debian 13 is a good alternative to Arch Linux when you want to install a lightweight Linux on specific hardware, such as routers for example.

However, most of the time, this type of hardware does not have a graphics card, and therefore I can display an image, either during installation or when connecting to the device in question.

The only way is to be able to use the available serial port, and we will see together how to do that.

This trick works with all distributions using GRUB. Feel free to install Red Hat, for example, if you prefer.

Installation step

You can perform the installation using the standard Debian ISO (either the netinstall or the DVD1). Whichever you choose, we will then apply the changes once booted from the installation media.

When burning the ISO to a USB drive, again there are no particular steps to follow.

Once you are connected to the device, and have booted from the USB drive, select the Install option, but press the "e" key on the keyboard to enter the Grub entry editing screen.

Find the line that starts with "linux /boot"... and add the text below to the end:

console=ttyS0,115200n8
If the serial port is at a different speed, enter the speed in place of 115200.
The "delete" button will be useful for erasing text in case of a typo.
Indeed, the backspace button (conventional delete) does not behave the same way depending on the version of grub.

Below we will detail the defined parameters:

  • ttyS0: Defines the virtual port used by Linux for text output on the serial port
  • 115200: Port speed for displaying text
    • It is necessary that the transmitter and receiver be at the same speed
  • n: No parity bit
  • 8: Sequence sent encoded on 8 bits

Then you can press "CTRL + x" to launch the Grub entry with the specified parameters.

Post-installation phase

Once the installation is complete, it is necessary to modify the installed Grub so that it uses the serial number at each boot. You will most likely need to modify the Grub entry again for the first boot (same trick as in the previous step).

Once booted into the operating system, edit the /etc/default/grub file and specify the following parameter:

GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"
Of course, reset the serial port values on your device.

Once done, launch and activate the serial service, and update Grub.

systemctl enable serial-getty@ttyS0.service
systemctl start serial-getty@ttyS0.service

update-grub
If the "update-grub" command doesn't work, it's because the command isn't in the PATH. Run the command below to make it work:
/usr/sbin/update-grub

And there you have it, the trick is done, and it is possible to connect to a device via the serial port.