Reformatting a USB Flash Drive

Reformatting a USB flash drive can be difficult. For example, GParted often gets confused with USB flash drives that have been formatted with a Linux boot image. When GParted starts, you get a warning that the sector size is wrong, and the total USB flash drive size is incorrect too. Linux quietly automounts such USB flash drives as read only, and you are then surprised that you cannot create any files on them. Completely cleaning a USB flash drive under Microsoft Windows can be difficult too.

These are the steps to wipe out the partition table and optionally format the USB disk with FAT32 under Linux:


 * Attach the USB disk.


 * Find out what the USB disk is called on your system:

sudo fdisk -l


 * Unmount (not "eject") with your favourite file manager any filesystems on the USB device that get automatically mounted. Alternatively, with the command line:

mount | grep /dev/sdX umount /dev/sdXY


 * Run the following commands in order to clear the partition table:

sudo fdisk /dev/sdX p # print the partition table o # create a new empty DOS partition table


 * That could be enough. Afterwards, you can format the USB disk with the normal system tools. If you wish, you can create a FAT32 partition with fdisk too:

n # add a new partition t # change a partition type # Choose partition type 'b' W95 FAT32 #                   or 'c' W95 FAT32 (LBA) # Tool gnome-disk-utility seems to use type 'c' W95 FAT32 (LBA) for a 16 GB USB stick.


 * Do not forget to write your changes before you exit fdisk.

w # write table to disk and exit


 * If you created a FAT32 partition:
 * If your system automounted the USB disk again, it is probably mounting some old partition. unmount (not "eject") again any filesystems on the disk.
 * Format the new partition like this:

sudo mkfs -t vfat  -n "USB16GB"  /dev/sdXY


 * Make sure to enter a label that is different from the old one. A new label will help you avoid confusion if your system stubbornly remembers the old partition.


 * Eject the USB disk with your favourite file manager. Otherwise, sometimes it remains half-mounted in Linux and causes further confusion. Alternatively, with the command line:

sudo eject /dev/sdX