How to Create a Bootable USB in the Linux Terminal?

How to Create a Bootable USB in the Linux Terminal?

People often ask me how I create a bootable USB in Linux. I have a few preferred methods that I use depending on what is most convenient at the time. For example, when using a graphical user interface, I like to use Balena Etcher. If it is not installed, I can also use the basic disk utility software to accomplish the task.

You can also create a bootable USB in Linux using the terminal and the dd command. This can be a useful option if you prefer to use the command line or if you need to automate the creation of bootable USBs. Let's find out how to do this.

Listing all the drives.

First, connect the USB and then list the drives using the lsblk command. The output of the command will be as follows:

sda           8:0    1  14.9G  0 disk 
├─sda1        8:1    1     2G  0 part 
└─sda2        8:2    1    15M  0 part

Note that the name sda refers to the USB drive that I plugged in. The device name for your USB drive may be different. You can verify the correct name by checking the size of the device using the lsblk command.

The dd Command.

Once you confirm the name the next step is to flash the USB using desired ISO file. The basic syntax of the dd command is:

dd if=/path/to/input of=/path/to/output

The if option is used to specify the path to the ISO image that you want to write to the USB drive and theof option is used to specify the target device, which is the USB drive. For example, if=image.iso specifies the ISO image, and of=/dev/sdX specifies the target device, where X is the device name of the USB drive.

Displaying the Progress.

By default, the dd command does not display any output until the operation is complete, which can take several minutes. If you want to see the progress of thedd command, you can include the status=progress option, which will show a progress bar during the transfer. For example:

dd if=image.iso of=/dev/sdX bs=4M status=progress oflag=sync

This will give you an idea of how long you can expect the operation to take.

Using the Pipe Viewer.

You can also use the pv command to display the progress of the dd command. pv stands for "pipe viewer" and it is a tool that allows you to see the progress of data that is being transmitted through a pipe. Here is an example of how you can use pv with dd to create a bootable USB:

pv /path/to/input | dd of=/path/to/output bs=4M oflag=sync


dd if=/path/to/input | pv | dd of=/path/to/output

Final Words.

To conclude, there are several ways to create a bootable USB in Linux, including using a graphical tool like Balena Etcher, using the dd command in the terminal, or using the dd command with the pv command to display the progress of the data transfer.

Each method has its own benefits and drawbacks, and you can choose the one that best suits your needs and preferences. Just be sure to carefully select the correct device name for the USB drive and to back up any important data before creating the bootable USB. You may also need the root user privileges in that case use sudo command as a prefix.

I will see you in the next article. Until then, keep reading, exploring, and learning. Take care!