How to create bootable linux USB flash drive via CLI?

This post will show how to create a bootable Linux USB flash drive from the terminal and using just a dd command. It's required that you have downloaded an ISO of your choice, I'm going to use Fedora Workstation 32 ISO as an example. In my case it is required to have a Linux machine (20GB disk) and at least 2GB USB flash drive. Depending on distro it can be different. I prefer this method because it's easy and I don't need to install any additional software for that.

Create a bootable USB flash drive

  1. Insert USB flash drive into the USB port.
  2. Find the name of the USB drive. For that I found the easiest would be to use an lsblk command. This will output something like that:
Copy
1[aaron@dark-side ~]$ lsblk
2NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
3sda 8:0 1 14.6G 0 disk
4├─sda1 8:1 1 1.9G 0 part /run/media/aaron/MediaUSB
5├─sda2 8:2 1 11M 0 part
6└─sda3 8:3 1 22.9M 0 part
7nvme0n1 259:0 0 232.9G 0 disk
8├─nvme0n1p1 259:1 0 600M 0 part /boot/efi
9├─nvme0n1p2 259:2 0 1G 0 part /boot
10└─nvme0n1p3 259:3 0 231.3G 0 part
11 ├─fedora_localhost--live-root 253:0 0 70G 0 lvm /
12 ├─fedora_localhost--live-swap 253:1 0 11.8G 0 lvm [SWAP]
13 └─fedora_localhost--live-home 253:2 0 149.5G 0 lvm /home
14[aaron@dark-side ~]$

In that case USB flash drive is dev/sda, it can be different in your system. To identify the correct drive I usually check the size of the drive. This has been a good enough identifier.

  1. Unmount USB flash drive. For that I'm going to use unmount command.
Copy
1sudo unmount /dev/sda1
  1. Flash Linux ISO to a USB flash drive.
Copy
1sudo dd bs=4M if=/path/to/linux.iso of=/dev/sda status=progress oflag=sync

Make sure to use a correct device path and don't append partition number - In my case simply /dev/sda is enough. Also, replace /path/to/linux.iso with a path to Linux ISO file in your system.

When this command finish successfully then everything is done. Reboot the system and start installing :) Depending on a system you may need to configure your BIOS to boot from USB.

Summary

In this post I described a system of how I create a bootable Linux USB flash drive. I have only tested this flow with some distros and it seemed to work in every case. If you have any questions, suggestions then let me know in the comments below.

Available resources