ngetty - one daemon for all virtual consoles

  • ngetty-1.0.tar.gz (old)
  • ngetty-1.1.tar.gz (stable)
  • Index
  • About

    ngetty is a daemon that starts login sessions on virtual console terminals, on demand. It is a good replacement for all those getty processes started from init that, most of the time, are only taking up memory. When compiled statically with dietlibc, the ngetty binary size is only about 2k and uses considerably less memory than a getty. See pstree here.
    riemann$  ps uww -C ngetty 
    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    root 145  0.0  0.0   8   8 ?   Ss   Jan05 0:00 ngetty 1 2 3 4
    
    Ngetty is designed to stop including getty-like code in init programs.
    I used source and ideas from logind. Many thanks, Andre!

    There is a mailing list for ngetty. To subscribe, send an empty message to
    ngetty-subscribe@riemann.fmi.uni-sofia.bg
    Some delay is possible due to greylisting.

    Benefits

    Install

    Ready to use binary packages are here. I prepared them using
      make package CC='diet -Os gcc -W'
      make rpm
    
    If you have dietlibc already installed do
      wget http://riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1.tar.gz
      gzip -dc ngetty-1.1.tar.gz | tar -xv
      cd ngetty-1.1
      # Read the ngetty.8 manual page (man ./ngetty.8)
      # Browse lib.h (check if the LOGIN path is correct!)
      # Edit Makefile to taste
      make CC='diet -Os gcc -W'
      make install
      # If you want to install some additional programs do:
      make install_other
    
    To compile ngetty with glibc skip CC=... above.
      make
      make install
    
    It is possible to do also
      make dietbuild
      make install
    
    Last download and install dietlibc in current dir and then compile ngetty. It takes 1-2 minutes to build dietlibc (depends on how fast ist your CPU). See also here.

    Post install

    Browse the files: /etc/ngetty/Conf[.sed], /etc/ngetty/sample.Conf
    Execute ./init.d/ngetty start
    If all is right you'll have working terminals on
    /dev/tty{8|9|10} or /dev/vc/{8|9|10}
    Try to login/logout on some of them.

    Some logins requires the TTY variable. Set it in /etc/ngetty/Conf. How to do this see the manual page of ngetty. Examples:

      tty4=environ=,TERM=linux,TTY=/dev/tty4
      tty5=environ=,TERM=linux,TTY=/dev/tty5
      tty6=environ=,TERM=linux,TTY=/dev/tty6
    
    If you can login in the system then you can make ngetty default.
    You have to edit /etc/inittab file.

    Do this in two steps. Fist comment default getty on tty{4|5|6}
    and edit /etc/inittab like next:

    	 1:2345:respawn:/sbin/mingetty tty1
    	 2:2345:respawn:/sbin/mingetty tty2
    	 3:2345:respawn:/sbin/mingetty tty3
    	 # 4:2345:respawn:/sbin/mingetty tty4
    	 # 5:2345:respawn:/sbin/mingetty tty5
    	 # 6:2345:respawn:/sbin/mingetty tty6
    
    	 # Run ngetty in standard run-levels
    	 ng:2345:respawn:/sbin/ngetty 4 5 6
    
    If your /etc/inittab have different entries only comment the last three of them and add two lines for ngetty as above. Now it's time to reboot the computer. After the reboot try to login/logout on tty{4|5|6}.

    If it is successful change /etc/inittab like:

    	 # 1:2345:respawn:/sbin/mingetty tty1
    	 # 2:2345:respawn:/sbin/mingetty tty2
    	 # 3:2345:respawn:/sbin/mingetty tty3
    	 # 4:2345:respawn:/sbin/mingetty tty4
    	 # 5:2345:respawn:/sbin/mingetty tty5
    	 # 6:2345:respawn:/sbin/mingetty tty6
    
    	 # Run ngetty in standard run-levels
    	 ng:2345:respawn:/sbin/ngetty 1 2 3 4 5 6
    
    and reboot again.
    That's all. You will have one ngetty instead of six {a|f|min}getty.
    If ngetty is compiled with dietlibc it will use 16k RAM only.

    WARNING: May be it's possible to make all without reboot. I don't use /sbin/init and don't know how to do this. The manual page init(8) says to use kill -HUP 1

    Using ngetty with other init systems

    If you use minit or ninit you have to make one new service ngetty, include it in
    default/depends and comment running getty there.

    The preparation of service ngetty is simple:

      mkdir /etc/ninit/ngetty
      cd /etc/ninit/ngetty
      ( echo '' ; echo TERM=linux ) > environ
      ( for f in 1 2 3 4 5 6 ; do echo $f ; done ) > params
      ln -s /sbin/ngetty run
    
    You can use ngetty also with runit. Start it as ordinary service. Since ngetty does utmp/wtmp records there is no need ot any additional setup.

    Using ngetty with other logins

    Ngetty uses the deafult /bin/login program. It's easy to use another login also.
    My login program is here. Copy it to /bin/nlogin and add in /etc/ngetty/Conf
    =login-prog=/bin/nlogin
    
    It's possible to start any program with arbitrary arguments using ngetty-argv helper.
    To use ngetty with fgetty logins add in /etc/ngetty/Conf
    =echo-off
    =login-prog=/bin/login1
       on debian system replace login1 with fgetty-login
    
    I still use startx script with my xinit.c.


    Author: Nikola Vladov

    Send comments and suggestions using ngetty mailing-list or qform.

    Last modified: 26 May 2010.
    Some comments about ngetty.