Dual booting Debian Jessie and Windows 8.1 on Dell Vostro 3800

This post is about a peculiar problem with the UEFI firmware that ships with the Dell Vostro 3800 (or maybe just some of its variants). This problem shows up when you try to dual boot GNU/Linux along side a Windows 8.1 (maybe even 8.0). If you are never gonna dual-boot into Windows, this post is not for you. This post assumes that you understand UEFI to some extent and are familiar with the tools. This is NOT a step-by-step instruction set. If you screw up, its your own problem.

Symptoms and constraints (all of these must hold true):
  1. You should be using GPT.
  2. You should be doing native UEFI boot.
  3. Secure boot should be disabled.
  4. After installing Debian GNU/Linux (Debian Jessie, in my case) along side the pre-installed Windows, on the FIRST boot, you should get the Grub boot-menu.
  5. From that boot-menu, if you choose "Debian GNU/Linux", your fresh installation should boot fine without issues.
  6. When you reboot, and choose Windows from the Grub boot-menu, Windows should boot fine without issues.
  7. When you reboot from Windows, you do not get the Grub boot-menu anymore. The computer boots into Windows by default. Basically, the first time you boot into Windows after installing GNU/Linux, your Grub is gone.
  8. At this point, boot into rescue mode using the Debian installer CD/USB/*. Choose your root partition, etc, and get to a shell. At the shell, do "efibootmgr --verbose":
    1. There should be an entry for "Windows Boot Manager"
    2. There should be an entry for "debian". But this entry will not have a "HD path" after the "Vendor" part (compare with the "Windows Boot Manager" entry).
  9. Delete the invalid "debian" entry.
  10. Add a valid entry for Debian.
  11. Reboot, hold F2 and get into the "firmware setup" (AKA BIOS setup). Go to the "Boot" options. The setup screen will not list any operating systems on your 'hard-drive'.
  12. If you continue to boot, the computer will boot into Windows.
  13. If you reboot into Debian installer's rescue mode and check the NVRAM using "efibootmgr --verbose", you see that problem in (8) has returned.
Now the explanation : The UEFI firmware on the mother-board is buggy. When there is more than one boot entry in the NVRAM, it gets confused.
  1. Before you installed Debian, "Windows Boot Manager" was the only entry, and the setup-firmware would have shown you that.
  2. Then when you installed Debian, 'grub-install' would have removed all NVRAM entries, and configured itself as the ONLY boot-manager because it knows how to load everyone else. So, the setup-firmware would have shown you "debian".
  3. When you boot-up Windows for the first time from Grub, Window's boot-manager got annoyed to see that it was not there in the NVRAM and adds itself there. It also sets itself as the default. Now, at this point both "Windows Boot Manager" and "debian" are listed in the NVRAM. But the "debian"entry got munged somehow (Not sure whose fault it is, the firmware or Windows).
  4. When you setup a valid entry for "debian" the UEFI-firmware did not understand it and therefore resorted to booting the default boot-manager in "\EFI\Boot\boot64.efi", which in turn loads the "Windows boot manager" in "EFI\Microsoft\Boot\". And, in the process the "debian" entry got munged again.
  5. In [1], there is a suggestion to install rEFInd for a similar problem. However, that will not work either. Coz, when windows loads up, if there is no "Windows boot manager" entry in the NVRAM, it'll install it. So, at any point there has to be two valid boot entries in the NVRAM. And, the UEFI firmware is having a problem with that.
The fix: Tell windows that Grub's boot-manager is its boot-manager. You can do this using:
bcdedit /set {bootmgr} path \EFI\debian\grubx64.efi
Once you do that, "Windows Boot Manager" (which gets chain-loaded from Grub) will ensure that the Grub's UEFI file is listed as the boot-manager in the NVRAM. So, you'll get the Grub boot-menu always :)

No comments: