How to Create Bootable USB from ISO using Linux Terminal

Channel: Linux
Abstract: $ dd bs=4M if=/tmp/ubuntu-20.04.1-desktop-amd64.iso of=/dev/sdc conv=fdatasync Where bs is read and write BYTES bytes at a time$ dd if=/tmp/ubuntu-18.

There are many third-party tools to create a bootable Linux USB Drive. Here I will show you how to create a bootable USB flash from ISO file using the Linux terminal.

Before we start make sure you have downloaded the .ISO file and have a USB flash drive with not less than 4GB capacity.

Check USB Drive

Connect the USB flash drive to your machine and check if it's connected successfully. Use lsblk command to list all information about the attached block devices.

How to Turn off Windows Update

To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video

How to Turn off Windows Update
$ lsblk

Sample Output:

$ 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 the following command:

$ 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:

Sample Output:

$ 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 /
Download Linux ISO File

Here we will create a Ubuntu bootable flash drive, first go to ubuntu website and download the iso file to your Linux computer. Or you can download iso file from the command line using wget or curl command.

This will download iso file to the current directory.

$ wget http://cdimage.ubuntu.com/focal/daily-live/current/focal-desktop-amd64.iso

or

$ curl -O http://cdimage.ubuntu.com/focal/daily-live/current/focal-desktop-amd64.iso
Create Bootable Drive from Terminal

We are going to use dd command to create a bootable USB flash drive.

Be cautious using the dd command of overwriting or deleting your data. Make sure you have backup

Syntax:

$ dd bs=4M if=/path/to/input.iso of=/dev/sd<?> conv=fdatasync

Where /path/to/input.iso is the path where .iso image downloaded. 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 ).

For example:

$ dd bs=4M if=/tmp/ubuntu-20.04.1-desktop-amd64.iso of=/dev/sdc conv=fdatasync

Where bs is read and write BYTES bytes at a time, if is the input file, of is the 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 pv command:

$ dd if=/tmp/ubuntu-18.04-desktop-amd64.iso | pv | sudo dd of=/dev/sdc bs=4M conv=fdatasync

Note: From 8.24 version of GNU Coreutils, dd command has the option to show the progress.

After the process is finished you can use USB as a bootable drive for ubuntu installation or repair.

Conclusion

Using the terminal to create a 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 a 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.

Ref From: linoxide
Channels:

Related articles