8

I just tried to open new terminal window and this error message displayed:

Failed to open PTY: No space left on device

It seems I can't open terminal window anymore unless closing existing one (or reboot). I don't have any other problem in my system.

My system:

Debian Buster (xfce4)
Linux debian 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux

Storage usage:

Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           786M  9.5M  776M   2% /run
/dev/sda4       320G  244G   62G  80% /
tmpfs           3.9G  315M  3.6G   9% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           786M   32K  786M   1% /run/user/1000

Inodes usage:

Filesystem     Inodes IUsed IFree IUse% Mounted on
udev             978K   455  978K    1% /dev
tmpfs            982K   872  981K    1% /run
/dev/sda4         21M  7.2M   14M   36% /
tmpfs            982K   394  982K    1% /dev/shm
tmpfs            982K     5  982K    1% /run/lock
tmpfs            982K    17  982K    1% /sys/fs/cgroup
tmpfs            982K    34  982K    1% /run/user/1000

Pretty sure there isn't any problem with storage or inodes count. I have closed all opened programs, after that I can open a few more terminal window, but still getting the error message.

0

2 Answers 2

7

You are looking in completely wrong place. Storage devices have nothing to do with PTY.

PTY is a "Pseudo Terminal Interfaces". It is responsible for creating connection from remote terminals. For example, you use xterm or ssh - the new PTY master channel is created on the actual machine.

Max number of PTYs (or remote connections) is defined in /proc/sys/kernel/pty/max. Its complement: /proc/sys/kernel/pty/nr, shows how many PTYs are currently in use.

For more detailed (and more official) explanation do man 7 pty.

3
  • 2
    I think that given the error message is "No space left on device" that thinking storage devices is not an unreasonable thought. This message could be a lot better - "Out of pty's" for example. Commented May 29, 2022 at 9:31
  • @ThorbjørnRavnAndersen The POSIX specifications dictate the error codes the standard system calls must return in specific error situations. Of course it would be possible to write a shell or other application with custom error-handling code for each instance of a system call with context-appropriate error messages, but writing, testing and localizing all those error messages would be a lot of (boring) work for the developers. Relying on the generic messages produced by strerror() is sort of a balanced approach between user friendliness, development effort, and reuse of well-tested code.
    – telcoM
    Commented May 31, 2022 at 8:55
  • 1
    @telcoM I know. Sometimes the founding fathers didn’t think of all the corner cases. This error message is simply misleading which is unfortunate. Just as in stackoverflow.com/a/16789621/53897 Commented May 31, 2022 at 9:37
1

Thanks @WhiteOwl for his/her great answer. Increasing maximum pty connections resolved the problem:

#Add this to /etc/sysctl.conf
kernel.pty.max = 1000
#Reload to apply new changes
sysctl -p
2
  • This post would have been more useful as a comment to @WhiteOwl to improve his answer. Commented May 31, 2022 at 9:51
  • I don't agree, the code will not maintain a good shape in comment. Maybe an edit is a better choice.
    – SAMPro
    Commented May 31, 2022 at 10:37

You must log in to answer this question.

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