Changes between Version 5 and Version 6 of runit/replaceinit


Ignore:
Timestamp:
Dec 21, 2007 10:40:41 PM (5 years ago)
Author:
jrollins
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • runit/replaceinit

    v5 v6  
    11= Replacing init with runit on Debian GNU/Linux = 
    22 
    3 This is based mostly on the [http://smarden.org/runit/replaceinit.html notes on replacing init with runit written by the runit developers]. 
     3This is based mostly on the [http://smarden.org/runit/replaceinit.html notes on replacing init with runit] written by Gerrit Pape, the main runit developer. 
    44 
    55Install the needed Debian runit packages: 
     
    1010== init == 
    1111 
    12 The runit-run installs the init replacement program, [http://smarden.org/runit/runit-init.8.html runit-int]: 
     12The runit-run package installs the init replacement program, [http://smarden.org/runit/runit-init.8.html runit-int]: 
    1313{{{ 
    1414proton:~ 0# ls -al /sbin/init* 
     
    1717proton:~ 0#  
    1818}}} 
    19 runit-int operation is very simple: 
     19runit-init's operation is very simple: 
    2020 * if it is started by root as process number one, then it just replaces itself with the [http://smarden.org/runit/runit.8.html runit] program. 
    21  * if not called by root, then it is called by "init 0", in which case it halts the system, or "init 6", in which case it restarts the system. 
     21 * if not called by the kernel, then it is called as "init 0" to halt the system, or "init 6" to restart the system. 
    2222 
    2323== runit == 
    2424 
    2525The [http://smarden.org/runit/runit.8.html runit] program executes three stages in succession: 
    26  * /etc/runit/1 - system one-time tasks, roughly equivalent to /etc/rcS.d (in fact it actually calls /etc/init.d/rcS, which in fact does this) 
    27  * /etc/runit/2 - which returns when the system is to be shutdown 
    28  * /etc/runit/3 - which shutdown the system 
     26 1. /etc/runit/1 - executes one-time system tasks, roughly equivalent to /etc/rcS.d (in fact it actually calls /etc/init.d/rcS, which in fact does this) 
     27 1. /etc/runit/2 - changes the runlevel to "default" and starts runsvdir on /var/service (which is linked to the current runlevel directory). returns when the system is to be shutdown 
     28 1. /etc/runit/3 - shuts down the system 
    2929 
    3030=== runit runlevels === 
     
    4141proton:~ 0# 
    4242}}} 
    43 Each of these are runit service directories that define the services that are to be started at the various runlevels.  /var/service is a link to /etc/runit/runsvdir/current: 
     43Each of these directories contain the services that are to be managed at the various runlevels.  /var/service is a link to /etc/runit/runsvdir/current: 
    4444{{{ 
    4545proton:~ 0# ls -al /var/service 
     
    6565proton:~ 0#  
    6666}}} 
    67 These service directories start the gettys, and the main system log daemons.  The next thing to do make service directories for the rest of the services that we want handled by runit.  This is where runit-services comes in.  runit-services provides service directories for a bunch of standard services, all located in /etc/sv: 
     67These service directories start the gettys, and the main system log daemons.  Once you figure out what services you want managed in a particular runlevel, you have to make their service directories.  The runit-services package comes with service directories for a bunch of standard services, all located in /etc/sv: 
    6868{{{ 
    6969proton:~ 0# ls /etc/sv/ 
     
    7474proton:~ 0#  
    7575}}} 
    76 /etc/sv/README gives a good intro on how to get these services started.  I'm going to start by getting the cron service working: 
     76/etc/sv/README gives a good intro on how to get these services started on a sysv-init managed system.  I'm going to start by getting the cron service working: 
    7777{{{ 
    7878proton:~ 0# /etc/init.d/cron stop 
     
    102102proton:~ 0#  
    103103}}} 
    104 An important one to me, which does not have an included service dir, is a serial console.  So I went ahead and wrote one: 
     104An important one to me, which is not included with runit-services, is a serial console.  This is the simple service directory I wrote to put a getty on ttyS0: 
    105105{{{ 
    106106proton:~ 0# ls -al /etc/sv/getty-S0/ 
     
    119119proton:~ 0#  
    120120}}} 
    121 Once the service directory was ready, I commented out the serial getty line ("TO:...") in /etc/inittab, told the current running init to reload the inittab, and then linked in the new service: 
     121Once the service directory was ready, I commented out the serial getty line ("TO:...") in /etc/inittab, told the current running init to reload the inittab (ie. stop the getty on ttyS0), and then linked in the new service: 
    122122{{{ 
    123123proton:~ 0# /sbin/init.sysv q 
     
    128128Notice I want it started in both "single" and "default" runlevels.  The serial console started up no problem. 
    129129 
    130 == todo == 
    131  
    132 I still need to write/find service directories for: 
    133  
    134  * ntpd 
    135  * udevd 
    136  * lvm 
    137  
    138130== reboot! == 
    139131 
     
    142134/sbin/init.sysv 6 
    143135}}} 
     136 
     137Success! 
     138{{{ 
     139proton:~ 0# pstree 
     140runit─┬─dhclient3 
     141      ├─events/0 
     142      ├─khelper 
     143      ├─ksoftirqd/0 
     144      ├─kthread─┬─aio/0 
     145      │         ├─kblockd/0 
     146      │         ├─khubd 
     147      │         ├─4*[kjournald] 
     148      │         ├─kmirrord 
     149      │         ├─kseriod 
     150      │         ├─kswapd0 
     151      │         └─2*[pdflush] 
     152      ├─runsvdir─┬─2*[runsv─┬─socklog] 
     153      │          │          └─svlogd] 
     154      │          ├─runsv─┬─sshd───sshd───bash───pstree 
     155      │          │       └─svlogd 
     156      │          ├─runsv───getty 
     157      │          └─runsv───cron 
     158      └─udevd 
     159proton:~ 0# 
     160}}} 
     161 
     162== todo == 
     163 
     164I'm curious about udevd.  It's started in /etc/rcS.d, and therefore by /etc/runit/1, but it's not being managed by a runsvdir.  Same question about dhclient. 
     165 
     166I also want to setup runsv directories for ntpd, and since this will be a home gateway, dhcpd, tinydns, and dnscache.