LoginSignup
12
9

More than 3 years have passed since last update.

VirtualboxでUEFI有効にしてDebian入れたら二度目には起動しない。お前さっきまで起きてただろ!

Last updated at Posted at 2016-08-15

結論

内容

  • VirutalBoxのUEFI NVRAMのバグ。
  • VirtualBoxのUEFIサポートは未だにexperimentalで、バグとしても扱う気はないらしい。
  • WindowsやRHEL/CentOS/Fedora/openSUSEはUEFI規格を無視してこのような壊れたUEFI firmwareの挙動を隠蔽する方向で対処している(そして互換性を破壊している)ので、問題が表面化しない。
  • 迂回したければ、以下の方法を取る
    • /boot/efi/EFI/{debian,ubuntu} を/boot/efi/EFI/boot にコピーする
    • /boot/efi/EFI/startup.nsh に FS0:\EFI\debian\grubx64.efi を記述する

経緯

そーいや、Debian上のVirtualboxでUEFI有効にしてDebianインストールすると初回は立ち上がるが二回目からダメ、という現象があって、むかーしむかしにバグレポート投げといたんだった

もうちょっと深追いしようね

  • 同じDebian vboxイメージをUSBディスクで運んでWindows10のVirtualBox5.1.2で動作するのか
    • いや、本当はVirtualbox5.0.2xでやったほうが良い気もするんだけども
    • それとも実はd-iのこのバージョンのバグで、今のだと直ってるかもしれないから、とりあえずstretch alpha5で入れる
  • 同じDebian vboxイメージをvirtualbox.org提供パッケージで動かしたらどうなのか
  • レポート中に「このパーティション、このフォーマットでいいの?」があるけど、このパーティションタイプを無理やり変えたらどうなのよ?

感想:セットアップがタルい。stretch alpha5途中でエラー吐いて止まるぞ。なんで前回すんなりはいってるの?>私
やり直し。眠い。ねm。。。

もいちど

  • Virtualbox 5.1.4 on Windows10 での Debian でも同様だった。
  • Virtualbox 5.0.24 on Debian で作ったイメージを Virtualbox 5.1.{2,4} on Windows10 に持って行っても同じ

この

  • インストール後、VMの電源を一度切らなければ大丈夫

というのがいやらしいな…

差分から原因を探る

Debian on 実機UEFIと Fedora on Vbox UEFIでは問題ない。ダメなのはDebian on VBox。

  • UEFIパーティション情報が違う?
    • 若干違うように見えるが、実質変わらず。
  • /boot 以下が違う?
    • ビンゴ。

Booting from UEFI shell by kicking /boot/efi/EFI/debian/grubx64.efi works.
Fedora24 on Virtualbox can boot without UEFI shell, and it has different files in its /boot/efi partition.

/boot/efi/EFI/BOOT/BOOTX64.EFI
/boot/efi/EFI/BOOT/fallback.efi

Once delete those files, Fedora24 won't boot. Probably VirtualBox UEFI seeks /boot/efi/EFI/BOOT, not /boot/efi/EFI/${distro}. I don't know this behavior is okay or not, but it's better to add workaround to d-i, IMHO.

Just copying those files (/boot/efi/EFI/BOOT/BOOTX64.EFI and /boot/efi/EFI/BOOT/fallback.efi) to Debian on VirtualBox won't boot, repeat putting error and rebooting.

根本的原因

https://wiki.debian.org/UEFI#Force_grub-efi_installation_to_the_removable_media_path だよ、と。

かいつまむと

  • いくつかのUEFI firmware実装が腐ってて、EFI/boot以下しか見ないっぽい。おかしいだろ
  • Windowsが腐ったUEFI firmwareに対応する方法として、リムーバブルメディア用に予約されてるディレクトリにEFIなファイルを突っ込むようにして問題を隠蔽した。
    • これは本来やっちゃいけない
  • そして、RHEL/CentOS・Fedora・openSUSEはWindowsと同じ挙動をするような実装にしている。お前らもかよ。。。
    • Debian/Ubuntuはspec守ってるから、VirtualBoxのUEFIのバグを踏んで起動しない。

そうは言ってもなんとかならんの?

https://wiki.debian.org/UEFI#Force_grub-efi_installation_to_the_removable_media_path に手動での対処方法書いてあるで。

...って面倒だから、VirtualBox環境だったら自動で処理するようなworkaround実装しない?と提案しておいた。
けど、蹴られた。うーん。

VBoxの方の問題

https://www.virtualbox.org/changeset/43256/vbox あたりを何とかすればいいんじゃね?という話。

12
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
9