トップ

当実験室について

室長プロフィール

報告書

日報

準備室
トップ報告書 → Cygwinを使い倒そう   【4】init編
■Cygwinを使い倒そう

 前回の報告書から結構な年月が過ぎてしまったが、Cygwin のx64版を再インストールするコトになったので前回までに書かなかった init の起動について説明する。

【4】 init編

 Cygwin を使っていくと様々なデーモン(daemon)を起動する必要が出てくると思う。それらのデーモンを cygrunsrv でWindowsのサービスとして管理してもイイのだが、ここは UNIX 風に init の管理下で起動する様にすると室長的には便利なのでそうしたい。

 init は全てのデーモンの親といえる。UNIXでは init が一番最初に起動されてから /etc/inittab の設定に従って次々にデーモンを起動していくので、UNIXのいわゆる背骨の様なモノと室長は考えている。んなワケでWindowsがブートする際に init が自動起動する様にしておこう。

 まずは Cygwin のコンソールを前回の報告書で説明した様に管理者として実行する。Cygwin コンソール画面で「init-config」と入力してエンターキーを押すのだが、その前に念の為、「cd /etc」「cp -p inittab inittab.org」を実行して、/etc/inittab ファイルを退避しておく。


$ cd /etc
$ cp -p inittab inittab.org
$ init-config
*** Query: Do you want to overwrite existing /etc/inittab file? (yes/no) no
*** Query: Do you want to overwrite existing /etc/rc file? (yes/no) yes
Creating default /etc/rc file

*** Warning: The following function requires administrator privileges!
*** Query: Do you want to install init as service? (yes/no) yes

*** Info: The init service has been installed under the LocalSystem
*** Info: account (also known as SYSTEM). To start the service now, call
*** Info: `net start init' or `cygrunsrv -S init'. Otherwise, it
*** Info: will start automatically after the next reboot.

*** Info: Check /etc/inittab and /etc/rc first, if they suit your needs.

Configuration finished. Have fun!
        

 init-config を実行すると最初に /etc/inittab ファイルを上書きするか尋ねられるので no と入力する。ちなみに yes と入力すると /etc/inittab ファイルが次の様になってしまうので要注意。残りの質問は yes にしておく。


# id:runlevels:action:processs
id:3:initdefault:
rc::bootwait:/etc/rc
#S0:2345:respawn:/sbin/agetty -L -T vt100 -n ttyS0 9600 ttyS0    
        

 この様な /etc/inittab は美しくないので、間違えて上書きしてしまった場合は退避してある /etc/inittab.org で上書きしてしまおう。


$ cp -p inittab.org inittab    
        

 「Configuration finished. Have fun!」と表示されていれば、init がWindowsサービスとして登録されているので「cygrunsrv -S init」の様に起動すれば完了である。


$ cygrunsrv -S init    
        

 次回は inetd デーモンの起動について説明したい。