Diff for /wikisrc/tutorials/how_to_use_ptyfs.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/20 20:55:21 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 **Contents**  **Contents**
   
 [[!toc]]  [[!toc]]
   
 #  What is ptyfs ?  #  What is ptyfs ? 
   
 ptyfs is a pseudo-terminal device file system written by Christos Zoulas. It first appeared in NetBSD 3.0.  ptyfs is a pseudo-terminal device file system written by Christos Zoulas. It first appeared in NetBSD 3.0. 
   
 #  How does it work ?  #  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.  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.  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 ?  #  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.  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 ?  #  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  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      file-system PTYFS 
          
   
 is uncommented, or available in your Kernel config file. Now, rebuild your Kernel and reboot.  is uncommented, or available in your Kernel config file. Now, rebuild your Kernel and reboot. 
   
 #  Setting up /dev/pts  #  Setting up /dev/pts 
   
 Change into the `/dev` directory and create the directory pts as root.  Change into the `/dev` directory and create the directory pts as root. 
          
     # cd /dev      # cd /dev
     # mkdir pts      # mkdir pts
          
   
 #  Testing ptyfs  #  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.  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      # mount_ptyfs ptyfs /dev/pts
          
   
 Check, if it is mounted:  Check, if it is mounted: 
          
     # mount      # mount
     # ptyfs on /dev/pts type ptyfs (local)      # ptyfs on /dev/pts type ptyfs (local)
          
   
 #  Editing fstab  #  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`:  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      ptyfs /dev/pts ptyfs rw 0 0
          
   
 #  Remote connections  #  Remote connections 
   
 New incoming remote connections are now acquired dynamically. You will notice that the new connections are called pts/* instead of ttyp*  New incoming remote connections are now acquired dynamically. You will notice that the new connections are called pts/* instead of ttyp* 
          
     # w      # w
     11:34PM  up  1:28, 2 users, load averages: 0.12, 0.10, 0.08      11:34PM  up  1:28, 2 users, load averages: 0.12, 0.10, 0.08
     USER     TTY     FROM                     LOGIN@  IDLE WHAT      USER     TTY     FROM                     LOGIN@  IDLE WHAT
     root     console -                        10:07PM     0 csh      root     console -                        10:07PM     0 csh
     john     pts/0   princeton.preston.edu    11:34PM     0 w      john     pts/0   princeton.preston.edu    11:34PM     0 w
          
   
 You're done. Have fun.  You're done. Have fun. 
   
 #  See also  #  See also 
   
   * [mount_ptyfs(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_ptyfs+8+NetBSD-current)    * [mount_ptyfs(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_ptyfs+8+NetBSD-current)
   
    [13]: http://netbsd.gw.com/cgi-bin/man-cgi?mount_ptyfs+8+NetBSD-current (http://netbsd.gw.com/cgi-bin/man-cgi?mount_ptyfs+8+NetBSD-current)     [13]: http://netbsd.gw.com/cgi-bin/man-cgi?mount_ptyfs+8+NetBSD-current (http://netbsd.gw.com/cgi-bin/man-cgi?mount_ptyfs+8+NetBSD-current)
   
 #  View source code (Please report any bugs or suggestions [here](http://www.netbsd.org/cgi-bin/sendpr.cgi?gndb=netbsd)).  #  View source code (Please report any bugs or suggestions [here](http://www.netbsd.org/cgi-bin/sendpr.cgi?gndb=netbsd)). 
   
   * [mount_ptyfs.c](http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/src/sbin/mount_ptyfs/mount_ptyfs.c?rev=HEAD)    * [mount_ptyfs.c](http://cvsweb.de.netbsd.org/cgi-bin/cvsweb.cgi/src/sbin/mount_ptyfs/mount_ptyfs.c?rev=HEAD)
   

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb