Formatting USBs with live Linux... what's the right way?

7 points by tomf 8 hours ago on tildes | 13 comments

Pavouk106 | 7 hours ago

You can do as root or via sudo:

dd if=/dev/zero of=/dev/sdX bs=1M count=1

where sdX stands for your USB flash (ie. sdc). Don't mess that up or you can destroy data on any of your disks in your PC! You won't be asked ANYTHING when you execute the command, it will get done!

This basically deletes the partition table of the disk, which in turn makes it completely blank (well, data is still written...). You have to partitipn and format it after doing that. You can use parted, fdisk or cfdisk to partition and then:

mkfs.fat -F 32 /dev/sdX#

where sdX stands for drive and # is the number of partition you want to format (ie. sdc1). You can use mkfs.exfat if you need exFAT instead of FAT32.

If you have anything to ask, do so. You want to be sure before you do anything.

archevel | 5 hours ago

If I just need an install medium and not a portable USB where I can store things I usually just do:

dd if=/some/path/<distro>.iso of=/dev/sdX bs=4M

And it's ready to go. No need to zero anything out unless you are using an old drive with sensitive info on. This is only useful if you don't intend to use it as a storage device though and only as an install media.

Pavouk106 | 3 hours ago

When you need to make bootable USB stick, your command is the easiest way. It will dump whatever is on the stick and make it bootable OS one.

I suppose my instructions could be called "get such USB stick back to being mass storage".

[OP] tomf | 6 hours ago

ok! yeah -- that totally makes sense. I don't get why the GUIs can't do the same. Excellent write up!

Nihilego | 5 hours ago

Does gparted not work or come installed with the Live USB?

Pavouk106 | 3 hours ago

GUIs can't do many things because even though they pften use the same commands in the background, their developer didn't add all the possibilities of the said command-line program.

I used some GUI programs back in the day to do video re-encoding (no editing, just encode to different format) and since some didn't allow for custom bitrate, some didn't allow for custom resolutions, some didn't allow for specific codecs... I just learned how to use ffmpeg in command line. Since then, I don't bother with GUI programs when I just need to re-encode video.

I learned a lot since my beginning days with Linux. And the most useful thing I learned is to use command line when possible.

FYI, you don't actually need dd for this. You can just run cat /dev/zero > /dev/sdX (and burn ISOs with cp file.iso /dev/sdX). Unless you actually need something that requires specific block sizes, which you usually don't, you don't need dd.

https://www.vidarholen.net/contents/blog/?p=479

You can even run curl ... > /dev/sdX to just directly flash an ISO from a URL!

https://astrid.tech/2026/03/24/0/curl-to-dev-sda/

cc @archevel, @tomf

Pavouk106 | 15 minutes ago

Nice approach!

I just described how I would do it. You can do it in many ways, obviously.

first-must-burn | 2 hours ago

I have gotten a lot of good use out of gparted although admittedly not in the past 5-10 years. I have always used it with the Linux system rescue as a bookable CD, which probably dates my usage. It's a great tool for expanding Windows partitions without reinstalling Windows. I've even used it to copy a windows partition onto a new drive and then expand it. I like the visual aspect because it's easier for me to be sure that I'm doing what I think I'm doing. Also a lot of the operations you can stack up and visualize before you actually commit to the operation.

preposterous | 5 hours ago

If it often mounts RO, it’s possible the stock’s flash is failing and the internal controller blocks any writes to it. Doesn’t happen very often but if the stick is old and has been used a lot, it’s a possibility.

bo0tzz | 4 hours ago

I swear by https://github.com/ifd3f/caligula, it's a whole lot nicer and simpler than dd.

arqalite | 4 hours ago

Wouldn't Rufus be able to do it? You can tell it to not flash anything on it and just format as FAT32.

I haven't touched any other disk utility since Rufus came out (but tbh I also try out fewer and fewer distros as time goes on, Fedora and Zorin are good enough for my purposes).

Ventoy is really worth checking out as a modern way for bootable usbs. You just copy the iso on the ventoy partition of the usb and it works. Supports both windows and linux isos.
https://www.ventoy.net/en/index.html