起動失敗してgrubプロンプト(grub >)が出た場合の対処

調べるのが面倒なので、メモを残しておく。

1. パーティションの確認 (sda2から起動したい)

grub> ls
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)

2. パーティションの中身の確認

grub> ls (hd0,msdos2)/
bin/ boot/ dev/ ....
grub> cat (hd0,msdos2)/etc/redhat-releases
Fedora release 27 (Twenty Seven)
grub> ls (hd0,msdos)/boot/
.... initramfs-4.14-11-300.fc27.x86_64.img .... vmlinuz-4.14.11-300.fc27.x86_64 ...

3. 起動

grub> set root=(hd0,msdos2)
grub> linux /boot/vmlinux-4.14.11-300.fc27.x86_64 root=/dev/sda2
grub> initrd /boot/initramfs-4.14.11-300.fc27.x86_64.img
grub> boot

4 (必要に応じて) grubの再インストール

# grub2-install /dev/sda

5 (必要に応じて) ファイルシステムの復旧

今回はxfsが壊れていたので下記コマンドを実行。

# xfs_repair /dev/sda2

参考

https://jp.linux.com/news/linuxcom-exclusive/418274-lco20140625 26.7. GRUB 2 の再インストール Red Hat Enterprise Linux 7 | Red Hat Customer Portal