Changes between Version 5 and Version 6 of runit/replaceinit
- Timestamp:
- Dec 21, 2007 10:40:41 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
runit/replaceinit
v5 v6 1 1 = Replacing init with runit on Debian GNU/Linux = 2 2 3 This is based mostly on the [http://smarden.org/runit/replaceinit.html notes on replacing init with runit written by the runit developers].3 This 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. 4 4 5 5 Install the needed Debian runit packages: … … 10 10 == init == 11 11 12 The runit-run installs the init replacement program, [http://smarden.org/runit/runit-init.8.html runit-int]:12 The runit-run package installs the init replacement program, [http://smarden.org/runit/runit-init.8.html runit-int]: 13 13 {{{ 14 14 proton:~ 0# ls -al /sbin/init* … … 17 17 proton:~ 0# 18 18 }}} 19 runit-in toperation is very simple:19 runit-init's operation is very simple: 20 20 * 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 restartsthe 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. 22 22 23 23 == runit == 24 24 25 25 The [http://smarden.org/runit/runit.8.html runit] program executes three stages in succession: 26 * /etc/runit/1 - system one-timetasks, roughly equivalent to /etc/rcS.d (in fact it actually calls /etc/init.d/rcS, which in fact does this)27 * /etc/runit/2 - whichreturns when the system is to be shutdown28 * /etc/runit/3 - which shutdown the system26 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 29 29 30 30 === runit runlevels === … … 41 41 proton:~ 0# 42 42 }}} 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:43 Each 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: 44 44 {{{ 45 45 proton:~ 0# ls -al /var/service … … 65 65 proton:~ 0# 66 66 }}} 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 providesservice directories for a bunch of standard services, all located in /etc/sv:67 These 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: 68 68 {{{ 69 69 proton:~ 0# ls /etc/sv/ … … 74 74 proton:~ 0# 75 75 }}} 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: 77 77 {{{ 78 78 proton:~ 0# /etc/init.d/cron stop … … 102 102 proton:~ 0# 103 103 }}} 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:104 An 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: 105 105 {{{ 106 106 proton:~ 0# ls -al /etc/sv/getty-S0/ … … 119 119 proton:~ 0# 120 120 }}} 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: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 (ie. stop the getty on ttyS0), and then linked in the new service: 122 122 {{{ 123 123 proton:~ 0# /sbin/init.sysv q … … 128 128 Notice I want it started in both "single" and "default" runlevels. The serial console started up no problem. 129 129 130 == todo ==131 132 I still need to write/find service directories for:133 134 * ntpd135 * udevd136 * lvm137 138 130 == reboot! == 139 131 … … 142 134 /sbin/init.sysv 6 143 135 }}} 136 137 Success! 138 {{{ 139 proton:~ 0# pstree 140 runit─┬─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 159 proton:~ 0# 160 }}} 161 162 == todo == 163 164 I'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 166 I also want to setup runsv directories for ntpd, and since this will be a home gateway, dhcpd, tinydns, and dnscache.

