マルチブートの失敗でUbuntuが起動しなくなった時の対処

状況

Windows XPUbuntuデュアルブートマシンに、追加で Fedora をインストールした。
その結果、起動時のメニューで Windows XPFedora を選ぶとOSが起動するが、Ubuntu を選ぶと次のエラーが出て起動しなくなった。

Error 13: Invalid or unsupported executable format

Press any key to continue...

エラーの意味。

13 : Invalid or unsupported executable format
This error is returned if the kernel image being loaded is not recognized as Multiboot or one of the supported native formats (Linux zImage or bzImage, FreeBSD, or NetBSD).

http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_13.html

カーネルがフォーマットを認識できていない、とあるけどよく分からない。

確認したこと/考えたこと

解決方法

ライブCDを利用して既存環境を起動し、GRUBをrootパーティションにインストールし直す。

(参考)

詳細

(1)ライブCDを利用して既存環境を起動する

ライブCDは、既存環境と同じバージョンのものを用意する。

手元に Ubuntu9.10 のライブCDがあったので、ブートCDとしてなら使えるんじゃないかと思ったけど、次のエラーが出てダメだった。(当たり前か)

11 : Unrecognized device string
This error is returned if a device string was expected, and the string encountered didn't fit the syntax/rules listed in the section Filesystem syntax and semantics.

http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_13.html

次の場所から Ubuntu 10.04 LTS の Ubuntu Desktop 日本語 Remix CD を落として、ディスクに焼いた。

CDから起動する。起動画面で放置していると、インストール画面に進んでしまうので、素早く F6 キーを押して、ブートオプションを入力可能な状態にする。

「boot=casper」を「root=/dev/sda2」に変更し、Enter キーを押す。/dev/sda2 にしたのは、自分の既存環境がそこにインストールされているからであり、状況によって異なる。

これで既存のUbuntu環境が起動する。(自分の場合、1回目はなぜか失敗して、2回目で成功)

(2)GRUBをインストールし直す

Ubuntuのtipsページどおり( UbuntuTips/Others/RepairMbrWithGrub - Ubuntu Japanese Wiki)、GRUBをインストールする。ここも、 /dev/sda2 にするかどうかは、環境によって異なる。Ubuntuのrootパーティションを選ぶ。

# /usr/sbin/grub-install /dev/sda2
/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of thr MBR. This is a BAD idea..
/usr/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is descouraged..
/usr/sbin/grub-setup: error: if you really want blocklists, use --force.

エラーが出るので、--forceオプションをつけて再実行する。

# /usr/sbin/grub-install /dev/sda2 --force
/usr/sbin/grub-setup: warn: Attempting to install GRUB to a partition instead of thr MBR. This is a BAD idea..
/usr/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is descouraged..
Installation finished. No error reported.

その後、マシンを再起動。1つ目の起動メニュー画面で Ubuntu を選ぶと、2つ目の起動メニュー画面が表示されるようになった。そこでもう一度 Ubuntu を選ぶと、無事起動した。

以上。

ここでいう「2つ目の起動メニュー画面」とは、Fedora を入れる前に表示されていた起動画面で、WindowsXPUbuntu のみが選択肢にあるもの。つまり、今回ハードディスクの先頭(/dev/sda1)にあるGRUBを見た後、Ubuntuが選ばれると /dev/sda2 の古いGRUBを見にいく、という挙動をしているのだと推測している。ちがうかなぁ・・・

まあつまり、GRUBとかブートローダとか、基本を理解してから環境を構築しないと、痛い目をみるという話でした。とほほ。反省。