Installing to external USB Flash/HDD UEFI

I want to install Ubuntu to an external usb drive so as not to make any changes to the Laptop I am using (UEFI Windows 8.1 pre-instaled)

If I choose manual partitioning during installation and choose the USB drive for bootloader installation, is this enough to be able to boot from the USB drive by using the laptop to choose boot device at initial boot, or do I need to do any additional preparation?

Do I need to manually partition the USB drive up front as gpt or will the Ubuntu installer take care of it?

I have read of receiving grub errors when the USB drive is not plugged in, but as it should be installed to the USB drive so how can it error when not plugged in?


Ordinarily, installing Ubuntu will make the following changes:

  • Create partition(s) for Ubuntu and install Ubuntu files on that/those partition(s). These changes can be restricted to your external disk without too much difficulty, provided you pay attention during the installation process.
  • Install the boot loader. This can mean:
    • If the install is in BIOS mode, code will be written to the MBR and/or to the partition you select, as well as to other location(s) on the disk.
    • If the install is in EFI mode, files will be written to the EFI System Partition (ESP) identified by the installer. An EFI-mode install will also modify the boot loader list maintained in NVRAM.

The type of installation you're suggesting makes controlling the boot loader installation difficult, since the Ubuntu installer's (Ubiquity's) tools for controlling boot loader location are a bit crude, particularly for EFI-mode installations. Unless you both know what you're doing and are very careful, you're likely to end up changing files on your internal hard disk. Most people who attempt this end up with GRUB partially installed on the computer's internal disk and partially on the external disk, meaning that the computer will fail to boot when you attempt to boot with the external disk unplugged.

Also, note that the boot mode is important. Your existing pre-installed Windows 8.1 is almost certainly in EFI mode. Installing Ubuntu in EFI mode is therefore advisable; however, be aware that the Ubuntu installation mode really only affects the boot loader. Thus, depending on how you do it, you might be able to install in BIOS mode (or on a BIOS-only computer), so long as you get an EFI-mode boot loader installed. (More on that shortly....)

There are basically two good ways to proceed:

  • Install to the external drive, but ensure that GRUB installs there, too, not to the internal drive. The best way to do this is to temporarily change the type code of the ESP on the internal disk, ensure that you've got an ESP on the external disk, and install normally in EFI mode. When you're done, you should change the type code of the internal ESP back to the right value and also copy EFI/ubuntu/ on the external disk's ESP to EFI/BOOT and rename shimx64.efi in that directory to bootx64.efi. This should make the external disk bootable like a USB drive. You'll be left with an altered NVRAM, but the entries will be automatically removed, or at least ignored. You'll have to use your firmware's boot manager to determine which OS to boot. A mistake could lead to the sort of problem I described, where GRUB will control everything and fail if you boot without the external disk plugged in. You'll then need to fix that problem by appropriate file juggling.
  • Launch the Ubuntu installation disk in its "try before installing" mode, open a Terminal, and then type ubiquity -b. This will cause the installer to install normally but to skip installing any boot loader. You'll have to correct this yourself by installing the boot loader of your choice. Semi-automated tools to install GRUB 2 exist, but are as likely to get it wrong as to get it right. The easiest solution is likely to be to install my own rEFInd from its .zip file by using the --usedefault option to install.sh, as in ./install.sh --usedefault /dev/sdb1 if your external disk's ESP is /dev/sdb1. Alternatively, since rEFInd doesn't rely on configuration files off the ESP, you can install it to your internal disk and the computer will still boot Windows when the external disk is unplugged, but rEFInd will mediate that boot process. You can install Ubuntu in either EFI or BIOS mode with this method. Note also that you might need to either disable Secure Boot or jump through extra hoops to install Shim if you use this method.

If you have a test/disposable computer, you can use it for your Ubuntu installation. That way, if something goes wrong, you won't have messed up the internal hard disk on your main computer, or its NVRAM entries.

Sorry these procedures are a bit sketchy; there are simply a lot of decisions you must make, and problems can be rather system-specific and difficult to predict.