In this article, we are going to show how to create a bootable USB flash drive from the terminal. We are going to use Ubuntu 18.04 ISO file for creating a bootable USB flash drive. You can download mentioned .ISO file from Ubuntu website. We are going to create the bootable USB drive without any third-party tools with GUI or not. If you are looking for GUI tools, you can use YUMI, Unetbootin, etc.
Before we start make sure you have downloaded the .ISO file and have USB flash drive with not less than 4GB capacity. Connect the USB flash drive to your machine and check if it's connected successfully. To do this type in terminal:
Output must be like this:
[email protected]:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 10G 0 disk └─sdb1 8:17 0 10G 0 part sr0 11:0 1 1024M 0 rom sdc 8:32 1 14.9G 0 disk ├─sdc2 8:34 1 2.3M 0 part └─sdc1 8:33 1 1.7G 0 part /media/linoxide/SANDISK sda 8:0 0 20G 0 disk ├─sda2 8:2 0 1K 0 part ├─sda5 8:5 0 1022M 0 part [SWAP] ├─sda3 8:3 0 7.9G 0 part └─sda1 8:1 0 9G 0 part /
From the list find your USB drive's mounted partition. In our case it's /dev/sdc1. It is mounted by default.
Next, we must unmount the USB flash drive by this command:
sudo umount /dev/sdc1
Make sure to change according to your USB drive and check if it has been unmounted again with
lsblk command. You must see the output without mount point in front of sdc1:
[email protected]:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 10G 0 disk └─sdb1 8:17 0 10G 0 part sr0 11:0 1 1024M 0 rom sdc 8:32 1 14.9G 0 disk ├─sdc2 8:34 1 2.3M 0 part └─sdc1 8:33 1 1.7G 0 part sda 8:0 0 20G 0 disk ├─sda2 8:2 0 1K 0 part ├─sda5 8:5 0 1022M 0 part [SWAP] ├─sda3 8:3 0 7.9G 0 part └─sda1 8:1 0 9G 0 part /
After USB flash drive is unmounted we can start the process of creating bootable USB drive. We are going to use
dd command to do the desired. But dd is a dangerous tool because it does what you tell it to do without questions. So please make sure to write all correctly, otherwise you may have data loss.
To start copying files on USB drive type this command in terminal:
sudo dd bs=4M if=/path/to/input.iso of=/dev/sd<?> conv=fdatasync
Where input.iso is the .ISO image downloaded from Ubuntu's website. Make sure to change <?> with your USB disk letter accordingly. The point here is to write the disk name itself (e.g. /dev/sdc) and not the partition (e.g. /dev/sdc1 ). In our case this command looks like this:
sudo dd bs=4M if=/tmp/ubuntu-18.04-desktop-amd64.iso of=/dev/sdc conv=fdatasync
bs is read and write BYTES bytes at a time,
if is the output file,
of is output file. The
conv=fdatasync bit is important as
dd can return before the write operation finishes.
By default the progress of the command will not be displayed, to view the progress you can use
sudo dd if=/tmp/ubuntu-18.04-desktop-amd64.iso | pv | sudo dd of=/dev/sdc bs=4M conv=fdatasync
After the process is finished you can use your bootable USB flash drive is ready. You can boot with it and either try Ubuntu or install Ubuntu.
Note: tests have been done on Ubuntu 16.04 to create Ubuntu 18.04 bootable USB flash drive.
Related Articles :
- How to use Linux lsblk Command to List Block Device Information
- How to Create Bootable Arch Linux on USB Drive
- Learn Linux DD Command - 15 Examples With All Options
Using the terminal to create bootable USB drive is much easier and way faster than with GUI tools. Also it is very useful to know how to do it in a terminal, because there isn't always GUI available. The main disadvantage in this case is that there is no double-check option for
dd. GUI tools help you to identify and select the target drive, and provide a final checkpoint, where you can double-check, that you will be writing to the correct drive.