1. What is ptyfs ?
  2. How does it work ?
  3. Why do I need it ?
  4. How do I use it ?
  5. Setting up /dev/pts
  6. Testing ptyfs
  7. Editing fstab
  8. Remote connections
  9. See also
  10. View source code (Please report any bugs or suggestions here).

What is ptyfs ?

ptyfs is a pseudo-terminal device file system written by Christos Zoulas. It first appeared in NetBSD 3.0.

How does it work ?

The traditional bsd style pty's are allocated to a fixed number of pty devices available. That is normally ttyp0 - ttyp9 and ttypa - ttypf which makes 16 ptys in total. There are also the groups of ttyq, ttyr, ttys* in the same way, which makes a total of 16 * 4 = 64 devices. This means, that no more than 64 remote connections to a NetBSD machine are possible.

ptyfs on the contrary is allocating the devices dynamically. That means, whenever a remote connection is established, a new device is created. This way the number of connections are only limited by the resources of the server.

Why do I need it ?

Normally you don't. You will need ptyfs, if you're going to run a server with hundreds (> 64) of remote connections (ssh or telnet). There are also a few applications like Matlab, that require ptyfs. I personally prefer ptyfs and use it on all my servers.

How do I use it ?

If you use NetBSD 4.0 or higher, ptyfs is enabled by default in all GENERIC Kernels. Otherwise, you have to rebuild your Kernel to use PTYFS. To enable PTYFS please ensure that the line

file-system PTYFS 

is uncommented, or available in your Kernel config file. Now, rebuild your Kernel and reboot.

Setting up /dev/pts

Change into the /dev directory and create the directory pts as root.

# cd /dev
# mkdir pts

Testing ptyfs

Before we change the file /etc/fstab, we have to ensure, that ptyfs is working. Otherwise your server won't be able to boot. To test if ptyfs is working, mount it manually.

# mount_ptyfs ptyfs /dev/pts

Check, if it is mounted:

# mount
# ptyfs on /dev/pts type ptyfs (local)

Editing fstab

You can now edit your /etc/fstab to mount it automatically everytime you boot. Please add exactly this line to your /etc/fstab:

ptyfs /dev/pts ptyfs rw 0 0

Remote connections

New incoming remote connections are now acquired dynamically. You will notice that the new connections are called pts/ instead of ttyp

# w
11:34PM  up  1:28, 2 users, load averages: 0.12, 0.10, 0.08
USER     TTY     FROM                     LOGIN@  IDLE WHAT
root     console -                        10:07PM     0 csh
john     pts/0    11:34PM     0 w

You're done. Have fun.

See also

View source code (Please report any bugs or suggestions here).

Add a comment