File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_use_ptyfs.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Sun Nov 20 20:55:21 2011 UTC (4 years ago) by mspo
Branches: MAIN
CVS tags: HEAD
import all of the how-to articles from the wiki



#  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 

  * [mount_ptyfs(8)](

   [13]: (

#  View source code (Please report any bugs or suggestions [here]( 

  * [mount_ptyfs.c](

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb