write iso directly to flash drive
Here’s a dumb problem you’ve never had:
You need to download an ISO to create a bootable flash drive, but you don’t have enough storage left on your system.
What can you do?
wget
to the rescue
wget
retrieves files by using popular application layer protocols found within the Internet protocol suite via the commandline. A traditional wget
workflow involves specifying a remote source to download and optionally explicitly specifying an output location like so:
sudo wget "https://example.com/file" -O /some/local/location
Since everything is a file, including attached devices, we can write the the downloaded file directly to our attached device.
demo
I’ll be using a live ISO of Fedora 34 in my example along with /dev/sdc
on my system. Be sure you specify the correct device (triple-check, then check again).
lsblk /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 1 57.3G 0 disk
└─sdc1 8:33 1 57.3G 0 part
write the ISO straight to your device:
sudo wget "https://download.fedoraproject.org/pub/fedora/linux/releases/34/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-34-1.2.iso" -O /dev/sdc
...
Length: 2007367680 (1.9G) [application/octet-stream]
Saving to: ‘/dev/sdc’
/dev/sdc 100%[=====================================================================================================================>] 1.87G 11.5MB/s in 4m 35s
2021-08-21 16:30:22 (6.95 MB/s) - ‘/dev/sdc’ saved [2007367680/2007367680]
note the new partitions
lsblk /dev/sdc
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 1 57.3G 0 disk
├─sdc1 8:33 1 1.9G 0 part
├─sdc2 8:34 1 9.9M 0 part
└─sdc3 8:35 1 20.9M 0 part
optionally you can use qemu-kvm
to verify your device is indeed bootable
sudo qemu-kvm -drive format=raw -hdb /dev/sdc
While this might not be very practical, it’s a neat little “did you know?” that showcases some of the best featues of Unix architecture.
further reading
wget
can do a whole bunch that I couldn’t possibly cover here, so I encourage you to learn more if you’re interested.