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
- Insert USB flash drive into the USB port.
- 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:
1[aaron@dark-side ~]$ lsblk2NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT3sda 8:0 1 14.6G 0 disk4├─sda1 8:1 1 1.9G 0 part /run/media/aaron/MediaUSB5├─sda2 8:2 1 11M 0 part6└─sda3 8:3 1 22.9M 0 part7nvme0n1 259:0 0 232.9G 0 disk8├─nvme0n1p1 259:1 0 600M 0 part /boot/efi9├─nvme0n1p2 259:2 0 1G 0 part /boot10└─nvme0n1p3 259:3 0 231.3G 0 part11 ├─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 /home14[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.
- Unmount USB flash drive.
For that I'm going to use
unmount
command.
1sudo unmount /dev/sda1
- Flash Linux ISO to a USB flash drive.
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.