GRUB2のインストール

テスト

./configure --prefix=/opt/grub2 でビルドしてインストール。
空きパーティション(/dev/sda3)に既存のカーネルをコピーして/bootにマウント。
grub-setup -f /dev/sda3 でパーティションブートレコードにgrub2をセットアップ。
grub.cfgを手書き作成。

set timeout=10
set default=0

menuentry "Linux" {
        set root=(hd0,3)
        linux /vmlinuz ro root=/dev/sda5 apm=power-off
}
既存(MBR用)のgrub legacyのmenu.lstに/dev/sda3へのchainload設定を記述。
title sda3
root (hd0,2)
chainloader +1

(2010.10.02)

本番インストール

./configure --prefix=/usr --sysconfdir=/etc でビルドしてインストール。

レスキューFDの作成

レスキューフロッピーを作る。

# grub-mkrescue --output=grub-rescue.flp
# dd if=grub-rescue.flp of=/dev/fd0 bs=1024

フロッピーブートしてコマンド手打ちでシステムを起動できることを確認する。

set root=(hd0,3)
linux /vmlinuz ro root=/dev/sda5 apm=power-off
boot

設定ファイルの作成

40_custom に設定をベタ書きすることにする。

# cd /etc/grub.d
# chmod a-x 00_header 10_linux 30_os-prober 
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

set timeout=30
set default=0

menuentry "Linux (sda5)" {
        set root=(hd0,3)
        linux /vmlinuz ro root=/dev/sda5 apm=power-off
}

menuentry "Linux (sda5) Previous Compiled" {
        set root=(hd0,3)
        linux /vmlinuz.old ro root=/dev/sda5 apm=power-off
}
# grub-mkconfig > /boot/grub/grub.cfg
# grub-install /dev/sda

[Up]