LinuxのGRUB

たとえば、FedoraCoreのクローンディスクをDeiveImageなどのWin系ディスククローンユーティリティで作った後、GRUBを再インストールする必要がある。


あるいは、LinuxGRUBで止まってしまった場合もGRUBを書き込み直す必要があるかもしれない。


ソースのディスクからOSを上げて、GRUB起動フロッピーを作る。
# dd if=/usr/share/grub/i386-redhat/stage1 of=/dev/fd0 count=1
# dd if=/usr/share/grub/i386-redhat/stage2 of=/dev/fd0 seek=1


GRUBディレクトリにgrub.confがあるのでプリントアウト等しておく。

■以下、FedoraCore4のgrub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.17-1.2142_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.17-1.2142_FC4 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.17-1.2142_FC4.img
title Fedora Core (2.6.11-1.1369_FC4)
root (hd0,0)
kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.11-1.1369_FC4.img

■■■■■■■■■


ディスティネーションHDDを取り付け、GRUB起動フロッピーから起動する。

grub> というコンソールが上がるので、grub.confを見ながら以下のように打っていく。


grub> root (hd0,0)
grub> kernel /vmlinuz-2.6.17-1.2142_FC4 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
grub> initrd /initrd-2.6.17-1.2142_FC4.img
grub> boot

これでLinuxがbootするはず。

次にGRUBをHDDのMBRにインストールする。

# which grub-install
/sbin/grub-install

# /usr/sbin/grub-install /dev/hda

以上です。