How to Install Ubuntu on a USB Flash Drive (Solution)

Written by: James Kiarie   |   Last updated: September 1, 2022

Ubuntu is one of the most widely used Linux operating systems among home users and enterprises. Ubuntu is normally installed by booting from a USB.

Installing the entire Ubuntu on a USB Flash drive is simple and straightforward. We need a bootable usb and another USB to which complete Ubuntu to be installed.

You can use ubuntu installed USB as a portable computer and bootable device. In this tutorial, we learn how to install the entire Ubuntu on a USB Flash Drive.

Prerequisites

  •  Laptop (with UEFI Boot).
  •  A live Ubuntu USB with at least 4 GB. (let's say USB 1)
  •  A USB drive on which to install Linux with a minimum of 32 GB. (let's say USB 2)

Recommended the USB where Linux is installed has to be USB 3.0, USB 2.0 might be slower or even not work. 

Problem

Since we are using the UEFI boot system, we have a challenge to solve. While installing Linux to the USB, its EFI files will be added to the ESP partition of the Laptop/system from where you performing the installation. ie its overwriting the UEFI boot loader of your computer system. This happens because the system keeps only one ESP partition live at a time.

The solution is to remove the ESP flag of the ESP partition from the disk of the system where you performing the installation. And enable it back before rebooting before the end of the installation.

An alternative method is to use a VirtualBox. When using a VirtualBox you only need one USB. The system settings of the VirtualBox allow enabling EFI so the Live OS correctly installs GRUB to the UEFI partition. Otherwise, it allows USB to use only on a Legacy boot enabled computer.

Install Ubuntu on a USB Flash Drive

Installing Linux onto a USB gives a full experience same as having it on a computer or laptop. The live distribution only gives a small testing experience and harder to store the data.

Let's look into how to install Ubuntu on a USB. Plug in both USBs to your PC.

Step 1: Create Live USB on USB

First, let's create a live USB (USB 1 in our case) using a USB creator.

  • Download Ubuntu from the official site.
  • Choose whether you want to download the desktop version or the server version of Ubuntu.
  • Download a USB creator. Here I am using Rufus.
  • Select the ISO image file of Ubuntu and click the flash button after selecting the USB drive.
  • Select the downloaded ISO file of Ubuntu and then click the start button.
  • It will ask whether to boot an ISO file or create a DD image.
  • It will take some time to boot Ubuntu into the USB drive.
Create Ubuntu live USB using Rufus
Create Ubuntu live USB using Rufus

Step 2: Boot using the Live USB 

Insert the live USB drive which we created in the previous step into the PC or Laptop. And then turn on the pc/laptop.

Enter BIOS using the bios key. Annoyingly many PC manufacturers use different keys to enter BIOS. Keep pressing repeatedly F1/F2/F10/F12/DEL key as soon as you power on the PC.

Choose Live USB to boot from BIOS
Choose Live USB to boot from BIOS

Choose the live USB drive to boot from and press Enter. You will see the Ubuntu Grub boot loader.

Grub boot loader
Grub boot loader

Click on "Try Ubuntu" button and proceed. By this option, we are going to use Linux without installing it into the hard drive.

Try Ubuntu using Live USB
Try Ubuntu using Live USB

Step 3: Turn off ESP flag

To fix the problem discussed before, we use the GParted tool to turn off the ESP boot flag on the EFI partition.

Search for the GParted tool after successfully starting the live mode of Ubuntu.

GParted
GParted

EFI system partition you can easily identify by name in the second column and also by flags column showing 'esp'.

Select the EFI partition

esp flag on Gparted
esp flag on Gparted

Right-click on the EFI system partition and from the menu click "Manage Flags".

Manage Flags
Manage Flags

Now you can disable the esp flag by unticking the checkbox.

turn off esp flag from EFI system partition using GParted tool
Turn off esp flag from EFI system partition using GParted tool

Now close the GParted tool.

On the welcome screen, we can see the Ubuntu 22.04 LTS icon. Click the icon to start the installation process of Ubuntu on the USB drive (USB 2) i.e. the USB drive with 32GB space.

Step 4: Installing Ubuntu to the USB

From here installation process starts to the USB ( in our case USB 2).

Select the language.

Click Language and Continue

Select the keyboard language.

keyboard layout
Choose keyboard layout

Select minimal installation. Normal installation may take more time, so recommend minimal installation, and later based on your requirement you can install packages individually.

Minimal installation
Minimal installation

In the 'Installation Type' section, select 'Something Else' so that the installer can present you with an option to install Ubuntu on your USB drive.

Installation type - Something else
Installation type - Something else

On the next screen identify the USB where to install Linux. You can easily find it by size. Once identified, select the device and click the minus button to delete any existing partition partitions.

Delete existing partition
Delete existing partition

This creates the "free space" and click the + sign in order to create an EFI partition.

Create EFI Partition
Create EFI Partition

Provide EFI partition details such as size (minimum size is 100MB), type, location, and use as (EFI system Partition). Then click OK button.

Provide EFI partition details
Provide EFI partition details

Using the remaining free space, create the root partition with the Ext4 filesystem. To make it simple keep everything under root.

Create root partition
Create root partition

The partition table is now complete with all the partitions in place. Select the newly created ext4 partition and click Install Now button to start the installation of Ubuntu on the USB drive.

Install to USB Device

The installer automatically detects your location on the World map. Alternatively, you can click anywhere on the map to change your location. When satisfied, click on 'Continue'.

Location
Location

In the next step, fill out your credentials including your name, computer's name, username, and a strong password. Then click 'Continue'

Set Computer Name and User details
Set Computer Name and User details

The installer will start installing all the software packages required by the system. Since the installation is being performed on a USB flash drive and not on a PC hard drive, the installation will take quite a while. So, just give it time as the installation progresses.

Installation in Progress
Installation in Progress

Once the installation is completed, it will pop up to restart and continue testing. Don't restart now.

Before restarting we need to turn on the ESP flag which we turned off before as a workaround for the problem. Click on the "Continue Testing" button.

Installation Completed
Installation Completed

Again go to the GParted tool. Follow Step 3 and turn on the ESP flag on the ESP partition.

Hurray !! All done. You can now shut down the PC and remove both USBs. You can now plug your USB drive into any PC and boot into your instance of Ubuntu that you have just created.

Conclusion

As demonstrated, the installation of Ubuntu to a USB drive is pretty similar to installing it normally on a PC. This is a very feasible solution for people who need to access complete Linux systems from any PC by just plugging in the USB.

However, the performance of Ubuntu on a USB drive is quite slow. It's therefore recommended to only carry out light workloads for best performance.

Thanks for reading, please let us know your experience in the below comment section.

About The Author

James Kiarie

James Kiarie

James Kiarie is a skilled and certified LPIC Linux administrator with a strong passion for technical writing, specializing in the Linux domain. With over four years of experience, he has crafted numerous technical guides, helping a wide audience navigate through various Linux distributions.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment