Install linux on an external drive without modifying Windows EFI partition

Install linux on an external drive without modifying Windows EFI partition

By Daniel
- Updated 2 years ago
10 comments

This article explains how to install Ubuntu Linux (or any other distribution) on a removable USB drive or stick without overwriting the EFI partition of your main hard disk and without using any shell commands, only graphical interfaces.

Live Linux USB drives are nice for testing purposes and with the new persistence modes they can also remember a few things between sessions. Unfortunately some features like the ability to update the OS or install drivers can only be accomplished with a full Linux installation.

It is possible to run a full Linux system in a removable drive but the installation process is tricky, even if you select the correct destination drive and the the correct destination for the boot loader you might end up with your main hard-drive boot partition overwritten and a USB stick that does not boot at all.

The main reason for this "unexpected behavior" are the extremely confusing and poorly implemented UEFI standards: the computer BIOS picks the EFI partition it finds first (on any disk) and boots from there. The lazy dumb Linux installers do not verify the location of this partition an simply load the boot instructions there without asking the user. Although this is OK for dual boot systems it will cause problems for users that do not want to contaminate their main disks.

One of the ways to prevent this is unplug the HD cable before the installation. Unfortunately newer computers and laptops use M.2 connectors without cables, removing and reinstalling the fixed HD is not that practical. Another alternative widely spread in forums is to perform the installation as usual and then repair the boot sequence of both the removable drive and the fixed drive, this procedure is complex and requires at least two devices, one for reading the instructions and the other to type the commands.

The procedure I will explain here does not require any shell commands, does not require rebooting the computer several times, does not require the main OS recovery disk (Windows or Mac), can be memorized just by reading this page, works with most graphical Linux installers based on Debian (Ubuntu, Kali, Lubuntu, Kubuntu, Mint, etc...) and has a lower probability of failing.

Everything perfect? Definitely not! You can still damage your main disk boot if you don't follow all the steps according to the instructions.

Requirements

This procedure is applicable for systems that use UEFI Mode (most of the computers shipped after Windows 7) with GPT. Devices that run on BIOS Legacy mode (MBR) do not require this procedure because the Linux Installer will place the boot loader where he is told to.

If you are not sure if your computer is using UEFI or Legacy mode just check the BIOS configuration menu.

Instructions

  1. Connect the destination drive and the source drive (Live Linux USB stick).
  2. Boot from the Live Linux stick.
  3. Select "Try Linux"
  4. When the graphical user interface loaded, run GParted (Partition Manager). If GParted is not available you can use the package manager from the live distro to install in the memory (it will be lost after reboot).
  5. Load the main Hard Disk drive (usually /dev/sda) and select the EFI partition (usually a FAT32 system).
  6. Edit the the flags of the EFI Partition and uncheck the "ESP" flag. Other flags will automatically change so take a note of the initial state before clicking anything.
  7. Apply the changes and do not reboot the computer until you revert that settings.
  8. Run the Linux installer from the desktop icon.
  9. Pick whatever partition scheme you want but remember to install the boot loader in the removable drive.
  10. When the installation ends, do not reboot the computer!
  11. Go back to the GParted application, select the the EFI partition and check back the "ESP" flag. Check other flags that were eventually turned off.
  12. Now reboot the computer and enjoy the new OS and the original untouched OS.
Select "Try Linux" option
Look for the fat32 EFI partition and manage it's flags

 

Disable the ESP flag in the EFI partition
Do not reboot after installing Linux, re-enable the ESP flags before
Re-enable the ESP flag in the EFI partition

Tags

Comments

Submitted by Mikhail on Sat, 03/25/2023 Permalink

It's an almost fine guide, but I see Ubuntu records added to my UEFI bios,

even if I unplug a hard drive with Ubuntu and load a computer with windows only.

I can't understand where the record is added, so it appears in BIOS

and in "bcdedit /enum firmware" list too

This is why I wrote this article. If you install Linux with your main Windows hard drive plugged, it will write to the UEFI partition of this drive unless it was previously disabled using this procedure.  

Submitted by Don Jacobs on Wed, 07/21/2021 Permalink

Great article.  I used this technique to install Linux on a second SSD with my main Windows installation on my primary M2 drive.  Worked amazingly well (with two varieties of Linux).  I had been looking for something like this for a long time; never liked the way Linux grub would overwrite the windows MBR.  In the past, I would just disconnect my Windows drive when installing Linux.  However, with Windows now on an M2 drive I didn't want to take the risk of unplugging (and possibly breaking) it. From now on, this will be my main Linux installation tool.  Thanks again.

Don

I've been using this method to install several different Linux systems on a second SSD.  My primary Windows drive is an M.2 drive. I like the way Linux will keep its "grubby" hands off of my windows MBR with this technique.   I noted that on several occasions, I forgot to reset the Esp and Boot flags on my M.2 drive after installing Linux.  However. . . it didn't seem to make any difference.  Windows booted up normally without issue.  Anyone have ideas if the resetting of the flags is always necessary?  

Submitted by Andrew P on Tue, 06/15/2021 Permalink

Seriously you are a rockstar. The amount of time I have wasted trying to make this work with UEFI is mind numbing and now I can have external bootable Linux drives of different distros with ease. Thank you so much 

Submitted by Paul on Fri, 05/28/2021 Permalink

Followed these instructions but now I get a grub rescue terminal when I try to boot from the external sdb drive . If I remove the drive windows 10 boots normally. Is there an easy fix for this?

Submitted by Ric on Tue, 04/20/2021 Permalink

Will this work on Mac too or it will mess the VRAM/PRAM? I found a lot of guides talking about this but none of those worked for me without messing the VRAM/PRAM. BTW, thanks for your guide!! It's a very creative trick removing the ESP flag ;-p