5

I have Ubuntu 16.04 and I note there are many devices in the /dev folder that don't physically exist.

For example, I have 2 serial ports and I can access them using ttyS0 and ttyS1 as expected.

However, in the /dev directory, I see 32 ttyS(n) devices and when I do an ls on them, there is no difference listed.

My question: What is the philosophy behind listing so many non existent ports? Why not have the OS make entries in the /dev dir only for ports that exist?

Thanks, Mark.

edit, I am speaking of serial ports ttyS(n) vs virtual consoles tty(n).

M.

Cool Javelin
  • 196
  • 6
  • It is my belief that those settings are set when you compile the kernel. To have it perfectly match your hardware it would be needed to recompile the kernel instead of just download a binary which is the default for Ubuntu. This would slow install, upgrades (it would require a re-compile) etc. As such the maximum generally required are set in the kernel. (USB is universal serial bus, and can use them in certain circumstances, but I can't be specific here) – guiverc Aug 03 '18 at 07:57
  • So, you are suggesting they took the lazy approach and placed the burden of actually verifying these ports on all other programmers who use the ports rather then taking the time to do it properly. The (slightly) better way is to detect them in POST and not recompile the kernel. Even better, they should be hot-swappable. Linux already automatically detects USB insertions and others. If I add a USB-to-serial adapter, the kernel should automatically add ttyS(n+1) in the devices dir. (Sorry, I guess I'm ranting a little.) – Cool Javelin Aug 03 '18 at 17:11
  • No it's not a lazy approach; in my opinion it's the best option available as it allows the fastest available for most of us that want speed and ease of use and just use binaries, and avoids the very much slower install, very much slower updates, plus extra space required to do this, plus have build tools present on a machine every time you upgrade or make changes (also avoiding a reboot). If you don't like the choice taken - there is nothing stopping you from compiling your own to perfectly match your machine. You have choice here; it's not made for you. – guiverc Aug 03 '18 at 22:28
  • 1
  • "What is the philosophy behind listing so many non existent ports?" There's none. Simply a preconfigured value for makedev script which is what screates them. – Sergiy Kolodyazhnyy Aug 05 '18 at 04:35
  • 1
  • OP edited question to side-step first duplicate candidate. As second duplicate candidate mentions the number of /dev/ttys is controlled by UART chipset. – WinEunuuchs2Unix Aug 06 '18 at 18:06
  • 1
    @SergiyKolodyazhnyy OP edited question so I nominated a second duplicate candidate. – WinEunuuchs2Unix Aug 06 '18 at 18:07

1 Answers1

2

You are only using 2 devices now, but system is able to work with as many as 32. Hence, name ttyS32 exists if you might need it. In old days there were just 4 Com ports, but now with hot swappable devices that can spawn synthetic ports, better if kernel claims control of the names it might use

pauljohn32
  • 3,743