G. Pape

runit - minimal replacement for sysvinit


How to install runit
How to replace init
How to use dietlibc

A collection of run scripts
Dependencies and runlevels

The runit program
The runit-init program
The svwaitdown program
The svwaitup program

The utmpset program


runit cooperates with the daemontools package to create a replacement for sysvinit. runit runs on Debian GNU/Linux sid/woody, OpenBSD 2.9, FreeBSD 4.4. runit reportedly runs on FreeBSD 4.3, and can easily be adapted to other unix operating systems. If runit runs for you on any other operating system or linux distribution, please let me know.

Warning: Replacing sysvinit or init can cause the system's boot to fail. Make sure you are able to recover and repair your system, for example if you run a boot loader, it should be able to pass init=/bin/sh to the kernel.


The command runit is intended to run as Unix process no 1, it is automatically started by the runit-init /sbin/init-replacement if this is started by the kernel.

runit performs the system's booting, running and shutting down in three stages:

These are working examples for debian woody: /etc/runit/1, /etc/runit/2, /etc/runit/3.

The command runit-init is intended to replace /sbin/init. sysvinit's command shutdown will keep working. On *BSD systems use init 0 for system halt and init 6 for reboot. Runlevels are not implemented in this Unix process no 1, such can easily be done in other programs, see Dependencies and runlevels for an example, the amount of code in process no 1 should be minimal.


runit in use: I replaced sysvinit with runit on several server systems and a laptop, all running Debian/GNU Linux woody or potato, some months ago and did not encounter any problems. This is from the second machine where I replaced sysvinit with runit:
  # strings /proc/1/exe |grep Id
  $Id: runit.c,v 1.5 2001/12/30 16:28:53 pape Exp $
  # uptime
   19:44:10 up 139 days,  1:09,  3 users,  load average: 0.00, 0.00, 0.00
  # ps axuw |head
  USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
  root         1  0.0  0.0    24   24 ?        S     2001   0:06 runit
  root         2  0.0  0.0     0    0 ?        SW    2001   0:09 [kflushd]
  root         3  0.0  0.0     0    0 ?        SW    2001   0:07 [kupdate]
  root         4  0.0  0.0     0    0 ?        SW    2001   0:35 [kswapd]
  root         5  0.0  0.0     0    0 ?        SW    2001   0:00 [keventd]
  root       149  0.0  0.1  1692  120 ?        S     2001   0:00 /usr/sbin/cron
  root       152  0.0  0.0  2196    0 ?        SW    2001   0:00 [svscanboot]
  root       154  0.0  0.1  1316  104 ?        S     2001   0:00 svscan /service
  root       155  0.0  0.0  1268   16 ?        S     2001   0:00 readproctitle service errors: ................
  # pstree
  runit-+-cron
        |-keventd
        |-kflushd
        |-kswapd
        |-kupdate
        `-svscanboot-+-readproctitle
                     `-svscan-+-2*[supervise---socklog]
                              |-18*[supervise---multilog]
                              |-5*[supervise---tcpserver]
                              |-supervise---qmail-send-+-qmail-clean
                              |                        |-qmail-lspawn
                              |                        `-qmail-rspawn
                              |-supervise---sshd---sshd---bash---bash---pstree
                              |-supervise---bash
                              |-2*[supervise---getty]
                              |-supervise---uncat
                              |-supervise---dhcpd-2.2.x
                              |-supervise---dnscache
                              |-supervise---tinydns
                              |-supervise---isdnlog
                              |-supervise---sleep
                              |-supervise---klogd
                              |-2*[supervise]
                              |-2*[supervise---vboxgetty]
                              |-supervise---clockspeed
                              |-supervise---squid---unlinkd
                              `-supervise---dhclient-2.2.x
This is from a more busy system:
  # strings /proc/1/exe |grep Id
  $Id: runit.c,v 1.6 2002/01/29 18:56:36 pape Exp $
  # uptime
   19:46:24 up 99 days, 19:56,  3 users,  load average: 0.15, 0.12, 0.12
  # ps axuw |head
  USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
  root         1  0.0  0.0    24    0 ?        SW   Feb07   0:05 runit
  root         2  0.0  0.0     0    0 ?        SW   Feb07   0:01 [keventd]
  root         3  0.0  0.0     0    0 ?        SW   Feb07   1:10 [kapm-idled]
  root         4  0.0  0.0     0    0 ?        SWN  Feb07   1:09 [ksoftirqd_CPU0]
  root         5  0.0  0.0     0    0 ?        SW   Feb07  13:23 [kswapd]
  root         6  0.0  0.0     0    0 ?        SW   Feb07   0:00 [bdflush]
  root         7  0.0  0.0     0    0 ?        SW   Feb07  10:18 [kupdated]
  root        53  0.0  0.0     0    0 ?        SW   Feb07   0:00 [msp3410 [auto]]
  daemon     115  0.0  0.0  1412    8 ?        S    Feb07   0:00 /sbin/portmap

See How to install runit for installing runit and How to replace init for smoothly escaping from sysvinit.
If runit on linux is compiled and linked with dietlibc it yields in a statically linked runit binary of 14k size and this ps axuw output on my system:
  USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
  root         1  0.0  0.0    24   20 ?        S    Nov22   0:01 runit
I recommend doing this; for instructions, see How to use dietlibc.
See http://smarden.org/runit/ for recent informations.
Related links:
Gerrit Pape <pape@smarden.org>
$Id: index.html,v 1.12 2002/05/19 11:10:43 pape Exp $