<<

Use this Linux tool instead of Balena Etcher

So simple, yet useful! Distrohoppers' paradise.


I was today years old when I learned that you can use the native Linux command cp to flash an .img file to a bootable device instead of using tools like Balena Etcher, Rufus, or yet another simple but comparatively bloated, dd.

Why is it useful

If you like distrohopping or maybe doing a project like making a Raspberry Pi homelab server, then you’re bound to come across “flashing a USB device” to make it bootable so that the hardware recognises the OS and… runs.

This “flashing” process usually involves of using software that I’ve mentioned already. But the cool part is you don’t need any of those! You already have it on your Linux machine!

sudo cp distro.img /dev/<block_device>

Does exactly this!

(A quick aside: you might be interested in using something like Ventoy for making a bootable device which contains multiple bootable images. Very useful if you need to have backup OSes and stuff.)

A little how-to

First, find out the device that you need to flash.

❯ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    1     0B  0 disk
sdb           8:16   1   7.5G  0 disk                             # <<< this is the device
└─sdb1        8:17   1   7.5G  0 part /run/media/nibir/691B-CB8B  # <<< notice the mount
zram0       253:0    0     4G  0 disk [SWAP]
nvme0n1     259:0    0 476.9G  0 disk
├─nvme0n1p1 259:1    0     1G  0 part /boot
├─nvme0n1p2 259:2    0   100G  0 part /
├─nvme0n1p3 259:3    0   360G  0 part /home
└─nvme0n1p4 259:4    0  15.9G  0 part [SWAP]

But make sure it’s unmounted: sudo umount /dev/sdb1 or whatever the device is.

Now, the key part is to cp the image file to the block device /dev/sdb not a partition /dev/sdbX (for any X). This will allow the image file to “do its thing” and make all the necessary partitions itself.

So finally:

sudo cp /path/to/distro.img /dev/sdb

Wait… and vóila! You know have a perfectly usable bootable USB drive. Oh and works with SD cards as well!

Happy tinkering! And don’t cp to your files partition~~~