6 方法わるよ

まえだこうへ

PIC
____________________________________________________________________

6.1 Squeeze から方法わる

Debian みにはSystem-V Unix では的な init (sysvinit) 使われていますDebian 6.0 (ドネSqueeze) からこれが upstart わる予定です年の 3 フリ予定8 リリ予定 Squeeze での予習味をめてはこの upstart わることになinit とのめた upstart 方法についてします

6.1.1

upstart Debian としたストリビであるUbuntu sysvinit として発されました sysvinit 的でしたみではありますが現在使われている ドウ使うには能面能面からてきていますそこでsysvinit みとして upstart にも複数トプロセスみが発されていますしかしUbuntu にも Fedora また Google Chrome OS, Chromium OS でも upstart されていますDebian でも Squeeze される予定ということもありsysvinit upstart 能性いのではないでし うか

6.1.2 そもそも init

upstart をするinit というけにまずしましinit 今更しなくてもとるがなという めてください

init Unix/Linux システムにおいてネルしたザプログラム動するためのみです えばあなたの使ているPC ている Debian システムでもこのみが必ず ていますマシンれてからログイン表示されるまでの流れはまかにはのようになり ま す



2: 流れ

PIC


init プロセス動するとinit /etc/inittab プロセスのを生成いますinittab のようになります

id:runlevels:action:process

プロセス生成わる部分には以下のようなものがあります

si::sysinit:/etc/init.d/rcS

l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5

ランレベル無いのはaction sysinit されているためですこれはステムブされ action よりも優先してされます/etc/init.d/rcS では

exec /etc/init.d/rc S

だけがされますこれは /etc/init.d/rc でのしますこのrc スクリプト するランレベルとしてされますがDebian でのデフルトランレベル 2 動され ます

id:2:initdefault:

なのでにはされます

l2:2:wait:/etc/init.d/rc 2

これにより /etc/rc2.d 以下イル名が SNN まるスクリプトNN 部分昇順となるように つずつされますこれが動がくなるつにもなていますただし同じレベルスクリプトして されるようにはなています

# Now run the START scripts for this runlevel.
# Run all scripts with the same level in parallel
CURLEVEL=""
for s in /etc/rc$runlevel.d/S*
do
        # Extract order value from symlink
        level=${s#/etc/rc$runlevel.d/S}
        level=${level%%[a-zA-Z]*}
        if [ "$level" = "$CURLEVEL" ]
        then
                continue
        fi
        CURLEVEL=$level
        SCRIPTS=""
        for i in /etc/rc$runlevel.d/S$level*
        do
                [ ! -f $i ] && continue

                suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
                if [ "$previous" != N ]
                then
                        #
                        # Find start script in previous runlevel and
                        # stop script in this runlevel.
                        #
                        stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
                        previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
                        #
                        # If there is a start script in the previous level
                        # and _no_ stop script in this level, we don’t
                        # have to re-start the service.
                        #
                        if [ start = "$ACTION" ] ; then
                                [ -f $previous_start ] && [ ! -f $stop ] && continue
                        else
                                # Workaround for the special
                                # handling of runlevels 0 and 6.
                                previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
                                #
                                # If there is a stop script in the previous level
                                # and _no_ start script there, we don’t
                                # have to re-stop the service.
                                #
                                [ -f $previous_stop ] && [ ! -f $previous_start ] && continue
                        fi

                fi
                SCRIPTS="$SCRIPTS $i"
                if is_splash_stop_scripts "$suffix" ; then
                        $debug splash_stop || true
                fi
        done
        startup $ACTION $SCRIPTS
done

動スクリプト動以にはランレベル 2 から 5 または2 3 にはコンソから getty されます action respawn となていますがこれは getty プログラム了したらinit 動させるための指示ですある コンソからログインしたログアウトすると getty 了しますがinit によりログイン けることができるというわけです

1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

init 他のとしてはシステム止時プロセスにもています

6.2 upstart とは

それではinit についての予備たところでupstart りましREADME にもされている upstart 徴は6 つです

sysvinit とはなりイベントドリブン同期タスクビス動されるきないでしただし Squeeze/Sid されている upstart sysvinit のものですupstart 標はイベントドリ ブントプロセスすることですがではsysvinit 動作しています *12

ma upstart 態遷のようになります*13



3: upstart 態遷

PIC


6.2.1 sysvinit わらない

Debian upstart のとおりDebian システム動・という部分えを ためのものがされていますsysvinit がない部分ですなおこの 6.2.1 6.2.2upstart README.Debian.gz されている FAQ をまとめ直したもの です

6.2.2 sysvinit

でもてが sysvinit 動作同じというわけではなくupstart 有の部分もありますgetty 連の わるきないです

6.3 upstart への

それでは早速 sysvinit から upstart えてみましSqueeze/Sid Lenny とのてみ ます

6.3.1 Squeeze/Sid での

Squeeze/Sid での upstart へのえにはupstart インストしますインスト なり続行するYes, do as I say しなさいという表示されますこれはえは リスクいためです

$ sudo apt-get install upstart
ジリストんでいます... 
存 関 ツ リ し て い ま す
ています... 
以 下 イ ン ス ト されます :
  dbus libdbus-1-3 libexpat1
:
  dbus-x11
以下されます:
  sysvinit
以下たにインストされます:
  dbus libdbus-1-3 libexpat1 upstart
:  以下されます
を し よ う と し て い る か に わ か て い な い してはいけません !
  sysvinit
プグレ: 0  インスト: 4  : 1  : 9 
1,005kB  カイブする必要があります
こ の 作 後  2,105kB  スクされます
こ す 能 性 の あ る こ と を し よ う と し て い ま す
続行するには’Yes, do as I say!’  というフレタイプしてください
 ?] Yes, do as I say!

lxc してみましたがgetty がうまく動かず動してはして動されて というのをしてしまうのでコンソからのログインないです *16

$ sudo lxc-start -n bootsid
cat: /proc/cmdline: No such file or directory
Setting the system clock.
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
Unable to set System Clock to: Tue Feb 9 14:16:26 UTC 2010 ... (warning).
Activating swap...done.
mount: you must specify the filesystem type
Cannot check root file system because it is not mounted read-only. ... failed!
Setting the system clock.
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
Unable to set System Clock to: Tue Feb 9 14:16:27 UTC 2010 ... (warning).
Cleaning up ifupdown....
Checking file systems...fsck from util-linux-ng 2.16.2
done.
Setting up networking....
Mounting local filesystems...done.
Activating swapfile swap...done.
Cleaning up temporary files....
Configuring network interfaces...done.
Setting kernel variables ...done.
Cleaning up temporary files....
Starting system message bus: dbus.
Starting OpenBSD Secure Shell server: sshd.
init: tty4 main process (239) terminated with status 1
init: tty4 main process ended, respawning
init: tty5 main process (241) terminated with status 1
init: tty5 main process ended, respawning
init: tty2 main process (242) terminated with status 1
init: tty2 main process ended, respawning
init: tty3 main process (244) terminated with status 1
init: tty3 main process ended, respawning
init: tty6 main process (245) terminated with status 1
init: tty6 main process ended, respawning
init: tty1 main process (306) terminated with status 1
init: tty1 main process ended, respawning
init: tty4 main process (307) terminated with status 1
init: tty4 main process ended, respawning
(snip)

ただしssh 由のミナルログインなくできました

$ ssh bootsid
Enter passphrase for key ’/home/user/.ssh/id_rsa’:
Linux bootsid 2.6.32 #1 SMP Mon Dec 7 05:27:50 UTC 2009 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Feb  9 14:18:38 2010 from 192.168.189.114
user@bootsid:~$

/etc/inittab getty エントリているのできているのかともいましたがそれはではありませ んでしたコンソからログインないことをけば一応使えるようですKVM/QEMU などのしなおしてみ さそうです

6.3.2 Lenny での

Squeeze/Sid でもうまくていないですのでSqueeze stable としてリリされるときに討しまし *17 るいはSid プグレすることを討してもいでし

6.3.3 まとめ

ではえているようですんなりなく使うのはではありますがにはオペレ 多少がありますUbuntu 9.10 されているネイテブモではオペレわるようです のではじめて upstart たというをきかけにぜひめに使みを予習しておくといで

61 エリア Debian 2010 2
____________________________________________________________________________________________