Select a serial port

Remote Serial Console HOWTO
Prev | Chapter 2. Preparation | Next

# 2.2. Select a serial port

## 2.2.1. Serial port names

Linux names its serial ports in the UNIX tradition. The first serial port has the file name `/dev/ttyS0`, the second serial port has the file name `/dev/ttyS1`, and so on.

This differs from the IBM PC tradition. The first serial port is named `COM1:`, the second serial port is named `COM2:`, and so on. Up to four serial ports can be present on a IBM PC/AT computer and its successors.

Most boot loaders have yet another naming scheme. The first serial port is numbered `0`, the second serial port is numbered `1`, and so on.

If your distribution of Linux uses the devfs device manager then the serial ports have yet another name. The first serial port is `/dev/tts/0`, the second serial port is `/dev/tts/1`, and so on.

The result is that the first serial port is labeled `COM1:` on the chassis of the IBM PC; is known as `/dev/ttyS0` to Linux; is known as `/dev/tts/0` to Linux when configured with devfs; and is known as port `0` to many boot loaders.

The examples in this HOWTO use this first serial port, as that is the serial port which most readers will wish to use.

Table 2-1. Many names for the same serial port

IBM PC | Linux kernel | Linux kernel with devfs | Most boot loaders
--- | --- | --- | ---
`COM1:` | `/dev/ttyS0` | `/dev/tts/0` | `0`
`COM2:` | `/dev/ttyS1` | `/dev/tts/1` | `1`
`COM3:` | `/dev/ttyS2` | `/dev/tts/2` | `2`
`COM4:` | `/dev/ttyS3` | `/dev/tts/3` | `3`

## 2.2.2. Cannot share interrupt used for console's serial port

When used for a console the serial port cannot share an interrupt with another device. The IBM PC devices are usually installed as shown in Table 2-2. If you use the serial port `/dev/ttyS0` for the console then you should avoid sharing interrupt 4 by not installing a serial port `/dev/ttyS2` in your PC. If `/dev/ttyS2` cannot be physically removed then disable it using the setserial command, as shown in Figure 2-1.

Table 2-2. Interrupts used for IBM PC/AT RS-232 ports

Device | Interrupt | Port
--- | --- | ---
`/dev/ttyS0` | 4 | 0x3f8
`/dev/ttyS1` | 3 | 0x2f8
`/dev/ttyS2` | 4 | 0x3e8
`/dev/ttyS3` | 3 | 0x2e8

Figure 2-1. Using the setserial command in `/etc/rc.serial`to disable the serial port `/dev/ttyS2`

    # Disable /dev/ttyS2 so interrupt 4 is not shared,
    # then /dev/ttyS0 can be used as a serial console.
    setserial /dev/ttyS2 uart none port 0x0 irq 0

Reading the source code suggests that the interrupt-sharing constraint applies to all computer architectures, not just Intel Architecture-32.

Prev | Home | Next
Create fallback position | Up | Select a serial speed and parameters