Installing Ubuntu Linux onto a USB stick will allow you to have a portable operating sysem that you can plug into any computer. This differs from a live environment USB, as installing Ubuntu directly to a USB stick will create a persistent operating system, the same way it does when you install to a typical hard disk. However, the process of installing Ubuntu to USB is not the same as a usual hard drive.
There are some differences in the installation process and important caveats to keep in mind if you plan to install Ubuntu to a USB stick. We will go over those in the sections below. In this tutorial, we will cover the step by step instructions to install Ubuntu Linux to a USB flash drive.
In this tutorial you will learn:
- How to install Ubuntu on USB Stick
|Category||Requirements, Conventions or Software Version Used|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Important things to keep in mind
Before you go forward with installing Ubuntu to USB, keep these things in mind:
- Your flash drive should be USB 3.0, or the speed of the operating system will be painfully slow
- You will need two flash drives – one as a bootable USB to install Ubuntu, and the other to install Ubuntu onto
- You may need to disable secure boot on PCs in order to boot from the USB, since it will contain its own EFI partition
The installation process will differ slightly from a usual one because we will need to temporarily disable the ESP flag on the current hard drive. This is because Ubuntu will not allow us to install an EFI bootloader onto the USB drive if one already exists on the system’s hard drive. The workaround is to temporarily disable the ESP flag, install Ubuntu to USB, and then re-enable the ESP flag afterwards.
How to install Ubuntu on USB Stick step by step instructions
We will be using “USB 1” to refer to the USB stick that is acting as an Ubuntu installer, and “USB 2” to refer to the USB stick on which we will be installing the persistent Ubuntu.
- The first thing we will need to do is create a bootable USB Ubuntu stick. Download Ubuntu and then use the following
ddcommand syntax to copy the contents over to USB 1.
$ sudo dd bs=4M if=/path/to/ubuntu.iso of=/dev/sdX status=progress oflag=sync
Of course, replace
/path/to/ubuntu.isowith the path to your ISO file, and replace
/dev/sdXwith the name of your device.
- Next, plug in both flash drives and reboot your PC. When it starts up, make sure you boot to the USB installer (USB 1) that we just created in the previous step.
- Once you arrive at the welcome screen, click on the “Try Ubuntu” option.
- Next, open up the
gpartedapplication from within Ubuntu’s
- In gparted, right click on your system’s EFI partition, which should be marked by the
espflag. Click on the option “Manage Flags.”
- Inside of the flag management menu, uncheck the ESP option. This is only temporary, and we will be putting this back on when we are done installing Ubuntu to USB 2. You can exit gparted after this step is completed.
- Next, it is time to install Ubuntu onto USB 2. Click on the desktop shortcut to install Ubuntu. Proceed to choose your language and keyboard layout in the following installation prompts.
- Once you get to the “Installation Type” screen, click on the option for “Something else” before clicking continue.
- Make sure you select USB 2 from the drop down menu, as we do not want to make any changes to USB 1 or your other disks in the system.
- If you already have some partitions on USB 2, you can delete them by highlighting them and clicking the minus sign on the partition menu. Highlight your free space and click on the plus sign to add a new partition. The first partition will be our EFI partition and contain the boot loader. Fill out the settings as seen below.
- Next, we will create the primary (root) partition which can simply span the rest of the USB stick. Fill out the settings as seen below.
- Next, continue with the rest of the installation as normal.
- Once the installation has completed, make sure you click on “Continue Testing.” Because we need to finish up by putting the ESP flag back on the EFI partition for our hard disk.
- Open gparted once again and repeat the steps from earlier, but this time adding the ESP flag back to the EFI (boot) partition of your hard disk.
- All done. You can power off the system from the GUI or use the following command:
Once the system is powered off, remove USB 1 from the computer (the USB drive which we used to install Ubuntu from). You can keep USB 2 in the PC, and try turning it on and booting to the USB stick. You should also be able to take your USB to other PCs and boot directly into Ubuntu. As mentioned earlier, keep in mind that you may have to disable secure boot inside of UEFI settings for each computer.
In this tutorial, we saw how to install Ubuntu Linux on a USB stick. While the performance is not nearly as good as installing Ubuntu to a traditional hard disk, it is a unique solution that allows us to carry around a full, persistent Linux installation in our pocket, and we would say that is pretty cool.