0

What I want to do is connect my PC to my terminal a DEC vt320 and be able to output the Linux console to it and for me to be able to type commands into the terminal and for it to send a reply on the screen. I wanted to connect to stuff from telnet but I don't know how to do it through serial. my serial connection is /dev/ttyS0

5
  • Do you want the linux console, or just a bash shell?
    – icarus
    Commented Mar 13, 2020 at 1:39
  • Which Linux version are you using? The answer may change, depending on distro. Commented Mar 13, 2020 at 1:43
  • I'm using Linux mint and it doesant matter if its the shell or the console. which ever ones easier to output Commented Mar 13, 2020 at 1:47
  • Which version of mint? Commented Mar 13, 2020 at 2:19
  • It is linux mint 19.3 Commented Mar 13, 2020 at 2:47

2 Answers 2

3

It looks like Mint 19.3 uses systemd, so unless Mint has modified the systemd configuration from what the parent distributions (Ubuntu and ultimately Debian) have, the following commands should do the job.

To start up a serial port for terminal-style login access immediately:

sudo systemctl start serial-getty@ttyS0 

To make the configuration persist over reboots:

sudo systemctl enable serial-getty@ttyS0

After running the first of these commands, a login prompt should appear on the terminal. If it doesn't, press Enter on the terminal once or twice: it can help in detecting the data transfer speed the terminal is operating at.

(The serial port speed is also sometimes known as baud rate, although that term would properly apply only to modem connections and similar where digital-to-analog modulation is involved, not to plain digital data transfer.)

This default systemd configuration for serial-attached terminals includes serial port speed auto-detection for speeds 115200, 38400 and 9600 bits per second. You can confirm this with command systemctl cat serial-getty@ttyS0. It will output the auto-generated unit file for that serial port. Among other things, it should contain this line that starts the actual process that will be managing the terminal:

ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM

If the automatic serial port speed detection does not work well for you, or if you want to specify a speed value that is not included in the default list, you would want to create an override file for this systemd service:

sudo systemctl edit [email protected]

This command will create the file (if necessary) and open it in an editor for you.

For example, to lock the serial port speed detection to 57600 bps, you would write the following three lines to the override file:

[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -- \\u' 57600 %I $TERM

The first line specifies that we want to override things in the [Service] section of the autogenerated service file, the second specifies that we want to override its ExecStart line and not just add another one, and the third line is the new ExecStart line with the desired port speed and/or other options for the agetty process that manages the terminal.

The traditional name for such a process in the Unix world is getty, and Linux typically uses an enhanced (alternative/autobauding) version of it for serial ports: agetty.

1
  • An override file will always be needed in this scenario to set the TERM environment variable, because the value of that variable inherited from systemd will always be wrong, there being no real terminal that matches the linux terminal type, let alone that type matching a DEC VT320 (which it overwhelmingly does not).
    – JdeBP
    Commented Mar 13, 2020 at 10:32
-1

The simplest answer is to just start up a terminal login service on the serial device, as in telcoM's answer. That does not change the Linux console. Moving the Linux console over to the serial device is simpler to enact, but has more side-effects.

Simply have console=ttyS0 in the kernel's command line, as supplied to it by a bootstrap loader (probably GRUB in your case).

The systemd-supplied generator will see that and automatically enable a serial-getty@ttyS0 service. But, moreover, all actual console output, from the kernel and from programs writing to /dev/console, will now go to your DEC VT320.

Unluckily, a VT320 does not support colour. (A VT340 does, and only 16 of them.)

This is unlucky because a lot of programs just hardwire ECMA-48 colour control sequences nowadays, including ones that spit out messages to /dev/console. The programs that come in the systemd package all do so, as long as the environment of process #1, which they go and read, does not contain TERM=dumb. Other programs make different decisions, often based upon their own process environments, and some make no decisions based upon terminal type at all, because the author never thought that the program's output might be a serial device with a real monochrome terminal.

So you also have to ensure that the kernel command line specifies TERM=dumb, which is not a correct description of a VT320, and is woefully inadequate.

Further reading

You must log in to answer this question.

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