1

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.

2 Answers 2

2

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).

1

Ubfan1's approach (putting an EFI System Partition, or ESP, on the external disk and putting a copy of GRUB there) should work. There are several potential stumbling blocks, though:

  • The existing external disk may well use the Master Boot Record (MBR) partitioning system, rather than the GUID Partition Table (GPT) that EFI favors. Although EFI usually works with MBR, that's not 100% certain. At the very least, it's a less well-tested option than GPT. Converting from MBR to GPT (via gdisk) can overcome this problem, if it becomes one.
  • An ESP must be created on the external disk. This will almost certainly require resizing at least one partition and creating a new one. This isn't all that big of a deal for experienced people, but it is at least a minor hassle.
  • Switching the boot between OSes will likely require use of the computer's built-in boot manager. These can be a bit awkward to activate -- they often require a keypress at system start time.
  • You'll need to get GRUB installed to the external hard disk. AFAIK, the GRUB setup scripts aren't designed for doing this, so you'll need to improvise. Ubfan1 has provided some useful end-point information, but getting from start to finish will take a lot more than that. GRUB isn't really the best choice for this sort of customized setup, either. Overall, I think this is the biggest potential problem with ubfan1's suggestion, since it requires going "off-script" from the usual GRUB setup, and GRUB is notoriously difficult to configure except via its configuration scripts.

An alternative is to put a Linux boot manager and/or boot loader on the existing ESP on the internal hard disk. This placement means that your preferred boot loader (GRUB or something else) can run every time the computer boots, so you won't need to deal with the machine's internal boot manager as often. You also won't need to repartition the external disk or convert it from MBR to GPT. Boot Repair might help automate the setup.

On the other hand, if GRUB's configuration file ends up on the external disk, it will fail to work at all if the external disk is removed. (It's possible to put GRUB's grub.cfg file and other necessary support files on the ESP rather than in Linux's /boot directory, but I don't recall the precise details of how to set this up.) Instead of using GRUB in this role, my own rEFInd boot manager might be a better choice. It can be tested from a USB flash drive or CD-R -- but the ready-made images for this don't support Secure Boot, so you'd need to disable that for testing. rEFInd should enable you to boot either Windows or (when the disk is plugged in) Ubuntu. Unless the GRUB setup goes easier than I'd expect, rEFInd should be easier to set up -- if rEFInd on USB flash drive or CD-R can boot your existing Ubuntu, just install the Debian package or PPA in Ubuntu and it should set itself up automatically to the ESP on the internal disk. (If the external disk also has an ESP, there's a chance that rEFInd would install there instead.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .