10

I have a laptop which is running windows 10 and I want to install Ubuntu on an external HDD and whenever I need it I can just plug it in and boot from the external drive.

I've followed a tutorial, actually two, and both said that the bootloader has to be installed on the external HDD. This had as a result that I could only access Windows when I had the external HDD plugged in. Whenever I didn't have it plugged in the laptop wouldn't boot and I would just get a black screen with a white line. After fixing my master boot record I could access windows.

Now I want to try again but I'm afraid that if I install the bootloader on the internal drive that I might somehow delete my windows partition or I will have problems with my bootup.

So what should I do?

1

4 Answers 4

12

First, it's CRITICAL that you understand your boot mode. Modern computers can boot in either of two ways:

  • BIOS -- This is the old way of booting, which was used on most computers introduced prior to 2011. Modern computers support BIOS-mode booting via a feature called the Compatibility Support Module (CSM), aka "legacy-mode boot support" or a similar term. Thus, this method can be referred to by three names: BIOS, CSM, or legacy. It involves 16-bit boot loader code splatted in the Master Boot Record (MBR) and various other places. It's an inelegant but mature method of booting, and most sites that don't explicitly mention the boot mode describe BIOS-mode booting. If your computer came with Windows 8 or later, though, chances are it does not use this method of booting.
  • EFI/UEFI -- This is the native boot mode for most computers introduced since mid-2011, and it is completely different from BIOS-mode booting, so you should ignore any advice that explicitly states it's for BIOS-mode booting, or anything that doesn't mention the boot mode (since it's likely to be old or written by somebody who doesn't know the difference). One exception: Confusingly, many people, and even computer manufacturers, refer to their EFIs as "BIOSes." This practice creates a great deal of confusion.

Since you mention Windows 10, chances are your computer is EFI-based and boots in EFI mode. I'll proceed under that assumption. If this is incorrect, ignore the rest of this answer.

To boot an internal disk in EFI mode, the OS typically stores a boot loader as a file on the EFI System Partition (ESP) on the disk. This filename can be anything legal, but for Ubuntu it will be EFI/ubuntu/shimx64.efi, which in turn launches EFI/ubuntu/grubx64.efi. The OS installer registers the name of the boot loader with the EFI's built-in boot manager, which stores that name in NVRAM. If the EFI works correctly (not all do), this results in a working boot process.

The trouble with this process, as applied to a removable disk, is three-fold:

  • The Ubuntu installer will install GRUB to "the" ESP -- but you may have multiple ESPs available (almost certainly one on the hard disk and maybe one on the USB drive). Controlling where GRUB installs can be tricky. It is not done by using the option marked with the obvious title about where to install GRUB. Instead, it can be done (AFAIK) only from the "Something Else" installation option by marking the ESP you want to use as an "EFI boot partition" or "EFI System Partition" (which name depends on the Ubuntu version).
  • If you install GRUB to the ESP on the USB drive, then when you remove the USB drive, the EFI may notice that it's got a registered boot loader entry that's not valid, and delete that entry. Many EFIs do this, and it means that if you install GRUB to an external disk and then unplug it, you lose the ability to boot from that disk, even when you plug the disk back in.
  • The way Ubuntu configures GRUB causes it to rely on configuration files that are in the Ubuntu /boot/grub directory, which is not likely to be on the ESP. Thus, if Ubuntu installs GRUB to the ESP on your internal disk, you'll avoid the first problem but run into another one because when you start up with the USB drive disconnected, GRUB will launch and be unable to find its configuration files. The result is a grub> prompt that will mystify most users.

There are a number of solutions to these problems, including:

  • Manual install of GRUB to the fallback filename on the external disk -- OS installers boot by using a fallback filename of EFI/BOOT/bootx64.efi. If you copy Shim (which launches GRUB) to this filename (by copying EFI/ubuntu to EFI/BOOT on the ESP and then renaming shimx64.efi to bootx64.efi in EFI/BOOT), your firmware will be able to launch your USB-based GRUB just as it did the Ubuntu installer. This will work past both of the problems I've just identified, but you'll need to use the computer's built-in boot manager to select which OS to boot. This built-in boot manager ranges from unusable to tolerable, so this might or might not be an acceptable solution. You may also need to tweak your boot order after you install Ubuntu to keep it from launching GRUB from either the internal disk's ESP or the external disk's ESP by default.
  • Put a /boot partition on your internal disk -- If you install GRUB to the internal disk, then you can also put a /boot partition on the internal disk. This will enable GRUB to work normally on all boots; however, the Ubuntu option will appear all the time, even when the USB disk is unplugged. This may be undesirable, especially if Ubuntu is the default. Also, this solution means that your external USB drive will be bootable only on the computer on which you prepared it. If you want to be able to use that disk on other computers, you should avoid this solution.
  • Use a smarter boot manager -- A boot manager gives you a choice of OSes to boot, whereas a boot loader loads a kernel into memory. GRUB does both jobs and the EFI's built-in boot manager does only the first job. There are other boot managers available, some of which may help you avoid the problems I've identified. My own rEFInd, for instance, if installed to the internal disk's ESP and made the default boot program, will detect and present an Ubuntu option if and only if GRUB or a Linux kernel is present -- that is, when the USB drive is plugged in. By setting the default_selection option in refind.conf appropriately, you can configure rEFInd to boot Ubuntu automatically if your Ubuntu USB drive is plugged in and to boot straight to Windows if the Ubuntu USB drive is not plugged in. My answer to this question provides more details about this type of configuration, albeit on a Mac rather than a PC.

With any luck, one of these approaches will get you up and running.

0
  1. Boot Ubuntu Live USB/CD
  2. Plug your external HDD in
  3. Install Ubuntu at External HDD ( advanced, so you can set where should the boot loader install )
  4. Config the bios to boot from your external hdd
1
  • This is a BIOS-based solution that won't work properly on most EFI-based computers.
    – Rod Smith
    Mar 23, 2016 at 17:35
0

You need to install the bootloader on whichever drive your UEFI/BIOS uses to boot. You can change this drive in your BIOS settings, which you can usually access by pressing something like F10, F12, or Del immediately after your computer starts. So as a first step, you can try setting your machine to boot from the external drive rather than the internal drive. If the bootloader is properly installed on the external drive, this should work.

For normal everyday use, you'll probably want to always boot from the same drive for the sake of convenience, so you'll want to install the bootloader to your internal drive. Before doing this, though, you should make a backup, preferably a full disk image of your working internal drive. If you encounter problems after installing Ubuntu alongside Windows, the Boot-Repair tool may help.

3
  • I've already changed the boot order to boot from a USB before the internal HDD. So I imagine if I install Ubuntu on the external HDD and install the bootloader in the external HDD I can but like I boot from the usb stick right?
    – captain
    Mar 23, 2016 at 14:23
  • Sorry, I'm not sure exactly what you're asking. You should be able to 1) install the bootloader on the external drive, 2) remove the USB drive, and 3) set your BIOS to boot from the external drive, then boot into Ubuntu on the external drive.
    – Ben
    Mar 23, 2016 at 14:28
  • @capitan Wright. Like i said, this would work.
    – Izzno
    Mar 23, 2016 at 18:44
0

I would install the boot loader on the External device! This way there is no chance of your windows installation corrupting or removing the bootloader. It would be a simple task setting your BIOS to boot:

USB-Key
USB-Disk
HDD
etc 
etc

NB: MAKE SURE YOU DISABLE SECUREBOOT (if you find that option)

This way if you disconnect the external device for some reason it will not pose an issue with your computer.

And: If you stay away from proprietary drivers you'll be able to run this system on other computers...

(Btw, I would not recomend this type of installation for permanant use as it will be slower than eSATA)

3
  • Ubuntu supports Secure Boot. Although there are occasional incompatibilities, they're rare, so there should be no need to mess with that setting. Under EFI, the boot order settings are typically much more complex than you describe, which is both good and bad -- it provides more options and more fine-grained control; but it means there's more to learn, and simple solutions learned in the BIOS world are unlikely to work.
    – Rod Smith
    Mar 23, 2016 at 17:35
  • I was unaware that ubuntu could "pose" as windows as all the Secure Boot BIOS options I have ever seen specifically states that it disables all abilities to change boot order permanently and or OS.
    – Izzno
    Mar 23, 2016 at 18:40
  • Ubuntu does not "pose" as Windows. Secure Boot simply requires an EFI program to be signed by a private key whose public key is registered with the firmware. Microsoft signs keys for third parties, including Canonical's Shim binary, making them runnable on computers that include Microsoft's key. I've never heard of a Secure Boot implementation that prevents altering the boot order, although I suppose a vendor might choose to add that restriction. See my page on Secure Boot for more on this topic.
    – Rod Smith
    Mar 23, 2016 at 23:53

You must log in to answer this question.

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