Linuxの起動関連のまとめ

起動プロセス

以下の順で起動
1.BIOS
2.MBR(マスタブートレコード)
3.ブートローダ(lilo,grub)
4.カーネル

ブートプロンプト

boot: linux root=/dev/hda3    ←/dev/hda3のディスクを指定
boot: linux 3                 ←ランレベル3で起動

LILOの動作

・第1段階ブートローダは第2段階ブートローダをメモリにロード
・第2段階ブートローダはマップファイルの先頭部分をロード
・ブートプロンプトを表示して待機
・プロンプトに対する入力を処理
・カーネルやinitrdをロード
・カーネルに制御を移して終了

LILOトラブルシューティング

LILOの起動段階の特定(L, LI, LIL, LILO, 010101エラー)
・L ....... 第1段階ブートローダの起動OK
・LI ...... 第2段階ブートローダのロードOK
・LIL ..... 第2段階ブートローダの起動OK
・LIL? .... 誤ったアドレスに第2段階ブートローダがロードされた
・LIL- .... 記述テーブルが破損している
・LILO .... マップファイルの先頭部分ロードOK、LILOが正常に起動

※起動トラブルの原因
・/sbin/liloの実行忘れ
・メディアの破損
・ディスクジオメトリの不一致

/etc/inittabファイル・・・起動時のランレベルやinitの設定

【構造】 A:B:C:D (Ex.「2:2345:respawn:/sbin/mingetty tty1」)
  A : ID(1~4字)
  B : ランレベル
  C : アクション指示子
  D : 実行されるプロセスと引数

【アクション指示子】
  initdefault : デフォルトのランレベル
  respawn : プロセスの処理後、再起動する
  wait : プロセスの処理完了まで待つ
  sysinit : 起動中に実行される(boot/bootwaitより先)
  boot : 起動中に1度だけ実行される
  bootwait : 起動中に1度だけ実行され、プロセスドの処理完了まで待つ
  ondemand : 独自に定義したランレベルの際に処理を実行
  powerfail : UPSに切り替わるとプロセスの処理を実行
  powerwait : powerfailと同じだが、プロセスの処理完了まで待つ
  ctrlaltdel : initがCtrl+Alt+Del(SIGINT)を受け取ると実行

ランレベル

0 停止
1 シングル
2 マルチ(テキストログイン,NFSは停止)
3 マルチ(テキストログイン)
4 未使用
5 マルチ(グラフィカルログイン)
6 再起動
S シングル(/etc/rc.d/rc.sysinitを実行)

ランレベルの確認方法

# runlevel
N 5    ←(直前のランレベル 現在のランレベル)
#

ランレベルの変更方法

# init 6
# telinit -t 60 5 (時間を指定できる)
※デフォルト値は、/etc/inittabに記述

停止

# shutdown -h now
# shotdown -r +5 "Please logout."
# shotdown -h +5 "This system will shutdown."
# shutdown -h 19:00
# telinit 0

LILOファイル(/etc/lilo.conf)・・・liloコマンドで変更反映

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
message=/boot/message
append="apm=on"
default=linux

image=/boot/vmlinuz-2.2.17-0vl10
        label=linux
        initrd=/boot/initrd-2.2.17-0vl10.img
        read-only
        root=/dev/hdb1

GRUBファイル(/boot/grub/grub.conf)

default=0
timeout=10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Red Hat Linux (2.4.18-14)
        root (hd0,0)
        kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/
        initrd /boot/initrd-2.4.18-14.img