How to create bootable USB drive in Ubuntu
Brief: This tutorial shows the steps for actually installing Ubuntu Linux on an external US drive with the bootloader installed on the USB. It is NOT live USB set up. This USB will work as portable operating system and can be used on any computer system.
Let me recall a few things.
A live USB is used for testing the distribution. It is also used for installing Linux on computer hard disk. Normally, any changes you made to your live distribution is lost and this limits the usage of the live USB.
Several of It’s FOSS readers requested a tutorial on installing Linux on a USB. Not the regular live USB with persistence but the actual Ubuntu installed on a USB disk.
This means having a portable Ubuntu Linux on a USB that you can plug it in to any computer, use it, save your work on the USB like it was an actual hard disk.
The procedure does not seem very different from installing Ubuntu on actual hard disk. And this is where people make mistakes.
Problem with bootloader on UEFI systems
The one major problem with this setup is bootloader installation on UEFI systems. A system can only have one active ESP partition at a time and it causes issues.
While installing Linux, even if you choose the USB as the destination for bootloader, the existing ESP partition is still used for placing the EFI file for the new distribution.
This means that the Linux installed on the external USB will be the last one to update and control the bootloader. This may create several problems like:
- The system you used for installing Linux on USB may not boot and end up with grub error if you don’t have the Linux USB plugged in.
- The Linux USB you created won’t boot on other systems because its EFI files are on the ESP partitions of the system which was used to install Linux on USB.
This fails the entire idea of having a portable Linux USB, right?
Worry not. I’ll share a neat trick for installing Ubuntu or other Linux distributions on a USB without messing up with the bootloader of the host system and the system on the USB.
Before you start following the tutorial, read it entirely and then go about doing it on your system.
Things to know before installing Linux on a USB
If you have a desktop PC, you may remove the hard disk and that could solve the problem but things will be difficult when it is a laptop. Removing the disk is out of question here.
An easier way out is to remove the ESP flag from the ESP partition before installing Linux on the USB and put it back after installation. This way, you fool the Ubuntu installer into thinking that there is no existing ESP partition and it will create and use a new ESP partition on the USB. The original ESP partition on the hard disk is untouched.
Clever trick, I know. Let me clear a few more doubts and add some suggestions:
- You’ll need two USB keys. One for live USB and another one where Linux will be installed.
- Use a USB of 4 GB for the live system and at least a 32 GB USB for the Linux USB.
- I highly recommend using USB 3.0 for both live USB and the actual Linux USB. USB 2.0 will be painfully slow for both installing and using Linux.
- Even if you use USB 3, installing Linux will be multiple fold slower than normal Ubuntu installation. Have patience and time.
- Using a Linux system from USB will always be slower than actual hard disk and SSD.
- When you want to use the Linux USB on a system, you’ll have to go to the boot settings to boot from the USB (unless the system is set to boot from USB by default).
- The Linux USB may not work with systems with secure boot enabled.
About the slower experience with Linux on USB, if your system has a thunderbolt port, I advise getting a thunderbolt SSD. I have a SanDisk SSD and when I used installed Linux on it, the experience was very smooth, almost like the SSD on the system.