Product SiteDocumentation Site

8.8. ブートローダの設定

ブートローダは既に機能しているかもしれませんが、ブートローダがマスターブートレコードから消えてしまった状況に備えて、ブートローダの設定方法とイントール方法を知っておくのは常に良い考えです。この状況は Windows などの他のオペレーティングシステムをインストールした後に起こる場合があります。以下の情報はブートローダ設定の変更が必要になった際にそれを変更するための助けになるでしょう。

8.8.1. ディスクの識別

Configuration of the bootloader must identify the different hard drives and their partitions. Linux uses “block” special files stored in the /dev/ directory, for this purpose. Since Debian Squeeze, the naming scheme for hard drives has been unified by the Linux kernel, and all hard drives (IDE/PATA, SATA, SCSI, USB, IEEE 1394) are now represented by /dev/sd*.
それぞれのパーティションは自分が存在するディスク上の番号で表されます。たとえば、/dev/sda1 は 1 台目のディスクの最初のパーティションで、/dev/sdb3 は 2 台目のディスクの 3 番目のパーティションです。
PC アーキテクチャ (つまり「i386」およびその年下のいとこである「amd64」) では、長い間「MS-DOS」パーティションテーブルフォーマットを使うよう制限を受けていました。このフォーマットはディスク 1 台当たりに作れる「プライマリ」パーティションの数を 4 つに制限していました。この制限を乗り越えるためには、プライマリパーティションの 1 つを「拡張」パーティションとして作成します。拡張パーティションには追加的な「セカンダリ」パーティションを含めることが可能です。このようなセカンダリパーティションには 5 以上の番号が割り振られます。従って、最初のセカンダリパーティションは /dev/sda5、2 番目は /dev/sda6 などのように割り振られるでしょう。
Another restriction of the MS-DOS partition table format is that it only allows disks up to 2 TiB in size, which is becoming a real problem with recent disks.
A new partition table format called GPT loosens these constraints on the number of partitions (it allows up to 128 partitions when using standard settings) and on the size of the disks (up to 8 ZiB, which is more than 8 billion terabytes). If you intend to create many physical partitions on the same disk, you should therefore ensure that you are creating the partition table in the GPT format when partitioning your disk.
どのディスクがどの SATA コントローラに (たとえば SCSI チェーンの 3 番目に) 接続されているかを記憶するのは常に簡単というわけではありません。なぜなら、特にホットプラグ対応のハードドライブ (これには多くの SATA ディスクや外部ディスクが含まれます) の名前は起動の度に変わるからです。幸いなことに、udev/dev/sd* に加えて、固有名のシンボリックリンクを作成します。曖昧でない方法でハードドライブを識別したい場合にはこのシンボリックリンクを使うことが可能です。これらのシンボリックリンクは /dev/disk/by-id に保存されています。たとえば 2 台の物理ディスクを備えるマシンでは以下のようなシンボリックリンクが見つかります。
mirexpress:/dev/disk/by-id# ls -l
合計 0
lrwxrwxrwx 1 root root  9  7月 23 08:58 ata-STM3500418AS_9VM3L3KP -> ../../sda
lrwxrwxrwx 1 root root 10  7月 23 08:58 ata-STM3500418AS_9VM3L3KP-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10  7月 23 08:58 ata-STM3500418AS_9VM3L3KP-part2 -> ../../sda2
[...]
lrwxrwxrwx 1 root root  9  7月 23 08:58 ata-WDC_WD5001AALS-00L3B2_WD-WCAT00241697 -> ../../sdb
lrwxrwxrwx 1 root root 10  7月 23 08:58 ata-WDC_WD5001AALS-00L3B2_WD-WCAT00241697-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10  7月 23 08:58 ata-WDC_WD5001AALS-00L3B2_WD-WCAT00241697-part2 -> ../../sdb2
[...]
lrwxrwxrwx 1 root root  9  7月 23 08:58 scsi-SATA_STM3500418AS_9VM3L3KP -> ../../sda
lrwxrwxrwx 1 root root 10  7月 23 08:58 scsi-SATA_STM3500418AS_9VM3L3KP-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10  7月 23 08:58 scsi-SATA_STM3500418AS_9VM3L3KP-part2 -> ../../sda2
[...]
lrwxrwxrwx 1 root root  9  7月 23 08:58 scsi-SATA_WDC_WD5001AALS-_WD-WCAT00241697 -> ../../sdb
lrwxrwxrwx 1 root root 10  7月 23 08:58 scsi-SATA_WDC_WD5001AALS-_WD-WCAT00241697-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 10  7月 23 08:58 scsi-SATA_WDC_WD5001AALS-_WD-WCAT00241697-part2 -> ../../sdb2
[...]
lrwxrwxrwx 1 root root  9  7月 23 16:48 usb-LaCie_iamaKey_3ed00e26ccc11a-0:0 -> ../../sdc
lrwxrwxrwx 1 root root 10  7月 23 16:48 usb-LaCie_iamaKey_3ed00e26ccc11a-0:0-part1 -> ../../sdc1
lrwxrwxrwx 1 root root 10  7月 23 16:48 usb-LaCie_iamaKey_3ed00e26ccc11a-0:0-part2 -> ../../sdc2
[...]
lrwxrwxrwx 1 root root  9  7月 23 08:58 wwn-0x5000c50015c4842f -> ../../sda
lrwxrwxrwx 1 root root 10  7月 23 08:58 wwn-0x5000c50015c4842f-part1 -> ../../sda1
[...]
mirexpress:/dev/disk/by-id# 
いくつかのディスクは複数回リストされています (なぜなら、それらは ATA ディスクであり同時に SCSI ディスクとしても振る舞うからです)。しかしながら、ディスクに固有の情報は主にディスクの製品番号とシリアル番号であるという点に注意してください。ここから、目的の周辺機器のシンボリックリンクを見つけることが可能です。
以降の節で挙げる設定ファイルの例はこれと同じディスク構成のマシンに対する設定です。具体的に言えば、1 台の SATA ディスクがあり、最初のパーティションに古い Windows がインストールされており、2 番目のパーティションに Debian GNU/Linux がインストールされている状態です。

8.8.2. LILO の設定

LILO (LInux LOader) は最も古い (実直だが素朴な) ブートローダです。LILO は MBR に起動するカーネルの物理アドレスを書くため、LILO および LILO の設定ファイルを更新した際にはその後に必ず lilo コマンドを使わなければいけません。このルールを忘れて、古いカーネルを削除したり、置き換えた新しいカーネルを古いカーネルがあった場所と同じディスクの場所に置かなかったりすると、システムが起動できないと表示されます。
LILO の設定ファイルは /etc/lilo.conf です。標準的な設定を行う単純なファイルは以下の例のように書けます。

例 8.3 LILO の設定ファイル

# このディスクに LILO をインストールします。
# ここではパーティションではなくディスクを指定してください。
# LILO は MBR にインストールされます。
boot=/dev/sda
# Debian がインストールされているパーティション
root=/dev/sda2
# デフォルトで起動させるアイテム
default=Linux

# 最新のカーネルイメージ
image=/vmlinuz
  label=Linux
  initrd=/initrd.img
  read-only

# 古いカーネル (最新のカーネルが起動しなかった際に使います)
image=/vmlinuz.old
  label=LinuxOLD
  initrd=/initrd.img.old
  read-only
  optional

# Linux と Windows のデュアルブート用
other=/dev/sda1
  label=Windows

8.8.3. GRUB 2 Configuration

GRUB (GRand Unified Bootloader) はより新しいブートローダです。カーネル更新の後に GRUB を実行する必要はありません。それどころか GRUB はファイルシステムを読む方法とディスクからカーネルを探し出す方法を知っています。GRUB を最初のディスクの MBR にインストールするためには、grub-install /dev/sda を実行してください。
GRUB 2 configuration is stored in /boot/grub/grub.cfg, but this file (in Debian) is generated from others. Be careful not to modify it by hand, since such local modifications will be lost the next time update-grub is run (which may occur upon update of various packages). The most common modifications of the /boot/grub/grub.cfg file (to add command line parameters to the kernel or change the duration that the menu is displayed, for example) are made through the variables in /etc/default/grub. To add entries to the menu, you can either create a /boot/grub/custom.cfg file or modify the /etc/grub.d/50_custom file. For more complex configurations, you can modify other files in /etc/grub.d, or add to them; these scripts should return configuration snippets, possibly by making use of external programs. These scripts are the ones that will update the list of kernels to boot: 10_linux takes into consideration the installed Linux kernels; 20_linux_xen takes into account Xen virtual systems, and 30_os-prober lists other operating systems (Windows, OS X, Hurd).

8.8.4. Macintosh コンピュータ (PowerPC) の場合、Yaboot の設定

Yaboot は PowerPC プロセッサを搭載する古い Macintosh コンピュータ用のブートローダです。古い Macintosh コンピュータは PC のように起動せず、「bootstrap」パーティションを使って起動します。「bootstrap」パーティションには、BIOS (または OpenFirmware) が実行する Yaboot が含まれ、さらに ybin プログラムがインストールする yaboot と設定ファイルも含まれています。設定ファイル /etc/yaboot.conf (このファイルは bootstrap パーティションにコピーされ、yaboot がディスク上からカーネルのパーティションを見つける方法を指定するファイルです) を変更したら、ybin コマンドを再度実行する必要があります。
ybin を実行する前に、適切な /etc/yaboot.conf を作らなければいけません。以下は最低限の設定例です。

例 8.4 Yaboot の設定ファイル

# bootstrap パーティション
boot=/dev/sda2
# ディスク
device=hd:
# Linux パーティション
partition=3
root=/dev/sda3
# 3 秒間何もしなければ起動します
# (timeout は 10 倍の値を設定してください)
timeout=30

install=/usr/lib/yaboot/yaboot
magicboot=/usr/lib/yaboot/ofboot
enablecdboot

# 最近インストールされたカーネル
image=/vmlinux
        label=linux
        initrd=/initrd.img
        read-only

# 古いカーネル
image=/vmlinux.old
        label=old
        initrd=/initrd.img.old
        read-only

# Linux と Mac OSX のデュアルブート用
macosx=/dev/sda5

# bsd=/dev/sdaX および macos=/dev/sdaX
# の可能性もあります