Changes between Version 3 and Version 4 of runit/replaceinit
- Timestamp:
- Dec 21, 2007 8:50:50 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
runit/replaceinit
v3 v4 8 8 }}} 9 9 10 The runit-run program is the one that actually replaces /sbin/init with /sbin/runit-init: 10 == init == 11 12 The runit-run installs the init replacement program, [http://smarden.org/runit/runit-init.8.html runit-int]: 11 13 {{{ 12 14 proton:~ 0# ls -al /sbin/init* … … 15 17 proton:~ 0# 16 18 }}} 17 runit-init is what will now start on boot and handle starting services. It also emulates many of the commands that could be passed to init. The configuration directory for runit-init is /etc/runit: 19 runit-int operation is very simple: 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 restarts the system. 22 23 == runit == 24 25 The [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 29 30 === runit runlevels === 31 32 runit has [http://smarden.org/runit/runlevels.html runlevels] that are defined in /etc/runit/runsvdir: 18 33 {{{ 19 proton:~ 0# ls -al /etc/runit/20 total 1021 drwxr-xr-x 3 root root 1024 2007-12-21 18:41 .22 drwxr-xr-x 51 root root 4096 2007-12-21 18:41 ..23 -rwxr-xr-x 1 root root 188 2006-11-04 14:33 124 -rwxr-xr-x 1 root root 576 2006-11-04 14:33 225 -rwxr-xr-x 1 root root 239 2006-11-04 14:33 326 -rwxr-xr-x 1 root root 209 2006-11-04 14:33 ctrlaltdel27 drwxr-xr-x 4 root root 1024 2007-12-21 18:40 runsvdir28 34 proton:~ 0# ls -al /etc/runit/runsvdir/ 29 35 total 4 … … 35 41 proton:~ 0# 36 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: 44 {{{ 45 proton:~ 0# ls -al /var/service 46 lrwxrwxrwx 1 root root 27 2007-12-21 18:41 /var/service -> /etc/runit/runsvdir/current 47 proton:~ 0# 48 }}} 37 49 38 The main service directory is /var/service (which is a link to /etc/runit/runsvdir/current, which is a link to either /etc/runit/runsvdir/default or /etc/runit/runsvdir/single, for default or single user mode, i think): 50 == services == 51 52 These are the default services setup for runlevel "default" by default: 39 53 {{{ 40 proton:~ 0# ls -al / var/service/54 proton:~ 0# ls -al /etc/runit/runsvdir/default/ 41 55 total 2 42 56 drwxr-xr-x 2 root root 1024 2007-12-21 18:41 . … … 51 65 proton:~ 0# 52 66 }}} 53 54 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: 55 68 {{{ … … 69 82 proton:~ 0# mv /etc/init.d/cron /etc/init.d/cron.distrib 70 83 proton:~ 0# ln -s /usr/bin/sv /etc/init.d/cron 71 proton:~ 0# ln -s /etc/sv/cron / var/service/84 proton:~ 0# ln -s /etc/sv/cron /etc/runit/runsvdir/default/ 72 85 proton:~ 0# sv status cron 73 86 run: cron: (pid 2033) 2s … … 84 97 proton:~ 0# ln -s /etc/sv/ssh/ 85 98 log/ run supervise 86 proton:~ 0# ln -s /etc/sv/ssh / var/service99 proton:~ 0# ln -s /etc/sv/ssh /etc/runit/runsvdir/default/ 87 100 proton:~ 0# sv status ssh 88 101 run: ssh: (pid 2059) 2s; run: log: (pid 2057) 2s 89 102 proton:~ 0# 90 103 }}} 91 92 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: 93 105 {{{ … … 107 119 proton:~ 0# 108 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: 122 {{{ 123 proton:~ 0# /sbin/init.sysv q 124 proton:~ 0# ln -s /etc/sv/getty-S0 /etc/runit/runsvdir/default/ 125 proton:~ 0# ln -s /etc/sv/getty-S0 /etc/runit/runsvdir/single/ 126 proton:~ 0# 127 }}} 128 Notice I want it started in both "single" and "default" runlevels. The serial console started up no problem. 109 129 110 130 == reboot! == 111 131 112 132 Finally, reboot your system:

