If you find an old, corrupted USB flash drive rattling around at the bottom of a desk drawer, or if you simply need to wipe a drive completely clean to securely store new data, dragging the files to the graphical trash can is not sufficient. You must properly format the entire partition to guarantee a clean slate and repair any file system errors. While graphical tools like GParted are useful, a Linux systems administrator can format a drive in mere seconds directly from the terminal using the powerful mkfs (Make File System) command.
Step 1: Identifying the Target Drive (CRITICAL)
If you format the wrong drive in Linux, you will instantly obliterate your entire operating system. You must precisely identify the USB drive before proceeding.
- Insert the USB drive into your Linux machine.
- Open your terminal and type the following command to list all block devices:
lsblk
Look at the output table. You will see your primary hard drive (usually sda or nvme0n1) and its partitions. Below that, you should see a smaller device that perfectly matches the capacity of your USB stick (for example, a 16GB drive might appear as 14.9G). Note the name of the partition on that drive (e.g., sdb1 or sdc1).
Step 2: Formatting the Drive
Once you are absolutely, one hundred percent certain of the drive identifier (we will use sdb1 for this example), you must unmount it before formatting.
- Type the following to unmount the drive:
sudo umount /dev/sdb1
- Now, format the drive to the highly compatible FAT32 file system (which can be read by Linux, Windows, and Mac). Type the following command, strictly replacing
sdb1with your actual drive identifier:
sudo mkfs.fat -F 32 /dev/sdb1
Press Enter. The Linux kernel will instantly obliterate the existing partition table and rebuild a fresh, perfectly clean FAT32 file system in milliseconds. The terminal will return to the command prompt when finished. The USB drive is now completely empty and ready to use.