How to Create a Bootable USB from ISO using the Linux Terminal?

Create A Bootable USB

CDs are long gone and if you want to reinstall an operating system, a bootable flash drive is required. You can use tools like Ventoy and Balena Etcher to do this task from a GUI, however, what’s the fun in that? Let’s learn how to create a bootable USB drive from an ISO on Ubuntu using the command line today.

We’ll be creating a bootable USB of the Ubuntu ISO file, but you can work with any ISO file that was designed to be written to a CD. You can also use these command on any Linux distribution.

How to Create a Bootable USB from ISO file?

So as I mentioned, we’re working with the Ubuntu ISO file here to create a bootable Flash Drive, but you can replace the ISO with any other ISO that’s built to be bootable and then follow the tutorial exactly as is.

For Ubuntu, we need a Flash storage drive with a minimum storage of 8GB, so we can have all the files. If you’re working with any other ISO or operating system, the storage requirements will be different.

1. Download the ISO File

To create a bootable Linux USB drive from the Ubuntu terminal, we need to download the ISO file first. In my case, I’m downloading the Ubuntu ISO file for version 20.04. You can choose to download the ISO for another operating system that you want to write to USB. You can follow this link to reach the Ubuntu download page – https://ubuntu.com/download/desktop

Select the ISO file which you wish to set up your bootable flash drive with. For this demonstration, we are using the Ubuntu 20.04 (Codename Focal Fossa). You can either directly download the file by clicking on the Download link on the page, or use the wget command to get the file on your system.

wget -c https://releases.ubuntu.com/20.04/ubuntu-20.04-desktop-amd64.iso

2. Connect and Identify the Flash drive

Once we have downloaded the correct disk image file, we will connect the USB Flash Drive. One that’s done, our next step is to figure out the drive name using the Linux fdisk -l command

sudo fdisk -l
Identify Your USB Drive
Identify Your USB Flash Drive

This will give you a list of all the disk drives that are available on the system. You’ll see a separate section with just a single disk path like /dev/sdb1 with a mount path that’s different from the common ones in Linux (like /home/, /etc/, /boot/ etc.). With Ubuntu, the default mount point is in the /media/ directory. Mine was mounted on the /dev/ directory.

3. Unmount the USB stick

Since Ubuntu automounts any external device that’s connected, we need to unmount it, so we can proceed to write the ISO to the USB. We use the umountcommand for this purpose. This action can be executed in two different methods.

The first method will involve using the path at which our USB device has been mounted. This command should look like this.

sudo umount /path/where/mounted

n this particular case, we will use the command as given below.

sudo umount /mnt

This will unmount the USB stick from our system.

Alternatively, we can use the device’s name in this format.

sudo umount /device/name

In this particular case, we will use the command as given below to unmount the USB stick.

sudo umount /dev/sda1
Unmount The Partitions
Unmount The Partitions

Now that the device has been unmounted, we will make a bootable drive using it.

4. Write the Linux ISO to the Flash Drive

Our Flash drive has been unmounted and our ISO file is already downloaded on our system. Now we will make this USB drive bootable for Ubuntu 20.04 using one single command. Use the following command in the terminal window:

sudo dd bs=4M if=/path/to/ISOfile of=/dev/sdx status=progress oflag=sync
  • This command requires us to use sudo privileges.
  • The bs (block size) tag reads the number of bytes which will be read from the source and written to the destination at a time.
  • The second tag, if denotes the path of the input file for the function
  • Whereas of denotes the path where the file has to be output to.

The thing about the dd command on Linux is that it will do anything you ask it to do without asking any questions. Hence, we need to use the command carefully. Before you begin writing, ensure that the output path is the path that you want to write the data to. There’s no turning back once the data has been written.

For our system, we will use the dd command as to create our bootable Flash drive for Ubuntu 20.04. Open a Terminal window and type the following command:

sudo dd bs=4M if=/home/Downloads/ubuntu-20.04-live-server-amd64.iso of=/dev/sdb1 status=progress oflag=sync

This should start the process of writing the ISO image file on your Flash drive and converting it into a bootable drive. You should see a screen as given below.

Ubuntu Bootable Disk
Ubuntu Bootable Disk

Once the file is written to the disk, you can use the sync command to verify that the file is indeed written to the drive without any error. Just type the following command in your Terminal window:

sync

Once you are done, which should take only a few minutes, your Flash drive is ready to work as a USB bootable disk for Ubuntu 20.04. You can now eject the drive and use it to install Linux on your friend’s laptop.

Wrapping up

There are multiple methods to create a bootable USB stick for the Ubuntu OS. Using the terminal for the task is a commonly used method because it eliminates the need for you to install any additional software. Further, it often takes less time to create a bootable USB stick from the terminal as compared to other methods like using the Startup Disk Creator or installing some other software.

Hence, this method is advisable even if you are not much comfortable with the terminal-based commands. It eliminates the need for any GUI software, which may be unavailable in some situations. The only major flaw in this method is the lack of a safe-check with the dd command, but it can be eliminated by carefully entering the command. This tutorial aimed to help you create a bootable USB disk from the Ubuntu terminal. If you have any feedback, queries or suggestions, feel free to reach out to us in the comments below.