Skip to content

Instantly share code, notes, and snippets.

@AnthonyZJiang
Created February 22, 2026 11:36
Show Gist options
  • Select an option

  • Save AnthonyZJiang/615732b14fb2187b177de9e927396702 to your computer and use it in GitHub Desktop.

Select an option

Save AnthonyZJiang/615732b14fb2187b177de9e927396702 to your computer and use it in GitHub Desktop.

Install Ubuntu on an External USB Drive (Portable Ubuntu)

This guide explains how to install a full Ubuntu system on an external USB drive or SSD, so you can plug it into any compatible computer and boot into your own Ubuntu desktop, with full persistence and saved settings.

Key idea

The main challenge on UEFI systems is bootloader isolation: by default the installer may mess with the host system’s ESP (EFI System Partition). The trick is to temporarily hide the host’s ESP from the installer so it instead creates its own ESP directly on the USB.


Prerequisites

  • Two USB drives:
    • One smaller USB (≥4 GB) for the live Ubuntu ISO.
    • One larger USB or external SSD (≥32 GB recommended) for the full Ubuntu install.
  • Prefer USB 3 or Thunderbolt SSD for acceptable speed when installing and booting.
  • Disable Secure Boot on the host system if it blocks booting from USB.

Step 1: Create a live Ubuntu USB

  1. Download an Ubuntu ISO from the official Ubuntu website.
  2. Use a tool such as Balena Etcher (or Startup Disk Creator on Linux) to write the ISO to the smaller USB.
  3. The result is a live Ubuntu USB that lets you boot into a temporary session and install Ubuntu on the other USB.

You are now ready to boot into the live environment and begin the full installation.


Step 2: Disable ESP flags from the host’s ESP partition

This step hides the host’s ESP from the installer so it does not touch the host’s bootloader.

  1. Plug in both USBs and boot from the live Ubuntu USB (“Try Ubuntu”).
  2. Open GParted:
    • Press the Windows key, type GParted, and run it.
    • If GParted is not installed, run:
      sudo apt update && sudo apt install gparted
      
  3. In GParted:
    • Select the internal hard disk (not the USB).
    • Locate the ESP partition (usually 100–500 MB, FAT32, with esp and boot flags).
    • Right‑click the ESP partition → Manage Flags.
    • Remove the esp (and usually boot) flag.
  4. Take note (or screenshot) of the original flags if non‑standard, so you can restore them later.

After removing the ESP flag, the partition often gains the msftdata type, and the system no longer sees it as an ESP. Changes apply immediately.

You can now proceed with installing Ubuntu on the external USB.


Step 3: Install Ubuntu on the external USB

  1. Ensure the bigger USB is plugged in and visible in GParted.
  2. On the live desktop, double‑click “Install Ubuntu”.
  3. Choose “Minimal installation” to reduce file count and speed up installation time.
  4. When you reach the “Installation type” screen:
    • Select Something Else.
    • Confirm that the host’s internal disk no longer shows an ESP because the flags were removed.
  5. Prepare partitions on the external USB:
    • Delete any existing partitions to create free space.
    • Create a new partition:
      • First partition: ESP (≈500–1000 MB, FAT32, esp flag enabled).
    • Allocate the remaining space:
      • Root partition: Ext4, mount point /.
    • [optional] create swap but it's better to it under root thanks to swapfile.
  6. Ensure the external USB is selected under “Device for bootloader installation”.
  7. Continue:
    • Set timezone, create user/password, and start installation.
    • The process will be slower than normal due to USB speed.

Important: Do not restart immediately after installation finishes. You must restore the ESP flags on the host disk first.


Step 4: Re‑enable ESP flags on the host

  1. In the still‑running live session, open GParted again.
  2. Select the host’s internal disk and locate the partition that was ESP (now likely shown as msftdata).
  3. Right‑click → Manage Flags and re‑enable the esp flag (and usually boot).
  4. Close GParted and then restart the machine.

If you accidentally rebooted before restoring flags, simply boot again from the live USB, correct the flags in GParted, and then reboot properly.


Step 5: Using the Ubuntu USB on other systems

  • Ensure the target system allows booting from USB and Secure Boot is disabled (if necessary).
  • At power‑on, press the boot‑menu key (often F2/F10/F12 depending on manufacturer) and select the Ubuntu USB.
  • You will see the GRUB menu; choose Ubuntu to boot.

You may see extra GRUB entries referencing OSes from the machine where the USB was installed. These are harmless but can be removed with grub‑customizer if desired.


Step 6: Reclaiming the USB drives

If you later want to reuse the USBs for normal storage:

  1. Use GParted (Linux, Windows, or macOS version) or a similar partitioning tool.
  2. Delete all existing partitions on each USB.
  3. Create a single partition formatted as NTFS or FAT32 for general‑purpose use.

Notes and caveats

  • Performance will always be slower than an internal SSD/HDD, especially with USB 2.
  • The ESP‑hiding trick only works while the host’s ESP is unflagged; forget to restore flags and the host may fail to boot without the USB plugged in.
  • For advanced EFI control (e.g., using the special fallback path), some guides also recommend using grub‑install with --removable on the USB’s ESP, though this is beyond the basic procedure above.

Credit

This is a cleaned up copy of Abhishek Prakash's work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment