Ubuntu – Install Ubuntu 14.04 on external HDD with Windows 8.1 UEFI

grub2hard driveuefi

I recently bought a new laptop, Lenovo Essential B50-70 MCC39MB Azerty, and I had an external HDD lying around with ubuntu 14.04 on it. I thought it would be nice if I could use this HDD whenever I wanted. Just plug it in and choose ubuntu in GRUB. So I followed these instructions.

But now I have this problem that when the external HDD is not connected, I get an error from GRUB. When I type 'exit', I can boot into Windows but this is not really practical. I just want the GRUB to show up when the HDD is connected, and boot into Windows otherwise.

I already searched for a bit and didn't really find an answer to this specific problem. Any help is greatly appreciated.

Best Answer

Unfortunately, the instructions were for a self-installed copy of Windows 8, so their setup was NOT a UEFI machine. Things are a little different for preinstalled Windows 8 on UEFI machines.

External (removable) boot devices should have their own 300M, FAT, EFI partition to hold the bootloaders. When you select the location for the bootloader (on sdb for the external), use this partition (which may work) instead of the device (which never works). When it doesn't work, the internal hard disk is used, so just copy the files from the internal disk's EFI to the external disk's EFI. Now, the installer still may not set up the bootloaders into the right directory for a removable device -- they should go into /EFI/Boot, and be named /EFI/Boot/bootx64.efi. Instead, grubx64.efi and shimx64.efi (the bootloaders) typically get put into /EFI/ubuntu (just like on the internal hard disk). I like to use shimx64.efi as the bootx64.efi file so the boot works whether secure boot is enabled or disabled. So, copy /EFI/ubuntu/shimx64.efi to /EFI/Boot/bootx64.efi (note the name change), and also copy /EFI/ubuntu/grubx64.efi to /EFI/Boot/grubx64.efi. The grub.cfg file may be left in /EFI/ubuntu.

The nvram boot entry for USB (disks...) should now boot the external disk -- no new entry in nvram should be needed. If you are getting grub without the external hard disk, looks like it got installed to the internal hard disk's EFI (no problem), and was put before the Windows bootloaders in boot order (problem). efibootmgr from Ubuntu will allow you to change the boot order, or delete the unwanted Ubuntu entry (remember, you will be booting with the USB entry).