Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a usb thumb drive that I want to reuse.

How can I format it?

share|improve this question
what distro are you using? – fromnaboo Jun 17 '12 at 7:38
I am using Ubuntu – Michael Durrant Jul 16 '12 at 2:13
up vote 7 down vote accepted

There are lots of different ways to do this.

Command Line

You don't necessarily need to ‘format’ (i.e. make a filesystem — you can't format USB sticks in the corrects sense of the word) the stick if you just want to delete all files.

Assuming the stick is mounted under /media/something, you can say:

sudo rm -rf /media/something/*

You will not be asked to confirm! This won't touch hidden files (recycling bin folders from Windows or Mac, etc).

If you want a pristine filesystem, make sure the filesystem is unmounted first:

sudo umount /dev/whatever_the_device_is
sudo mkfs.vfat -n "Volume Label" /dev/whatever_the_device_is

This will make a FAT filesystem. If you need an NTFS filesystem, there's always mkfs.ntfs, but you should be aware that some implementations are buggy. It depends on your distribution and how recent it is.


Fire up the KDE Partition Manager (if you don't have it, the Debian/Ubuntu package name is a slightly non-standard partitionmanager). Do the obvious thing.


Use the Gnome Disk Utility (Palimpsest). It's quite trivial to use: just select your USB drive from the left. If it has a partition already, click the ‘Format’ button. Otherwise, there's a ‘Format Drive’ button which'll do everything for you.

Ubuntu 11

Ask Ubuntu has this exact question already answered: How to format USB or external drive in 11.10? — note how this just walks you through using the Palimpsest Disk Utility.

Everything Else

My own favourite GUI tool for this job is GParted. It does everything you need (except, sadly, LVM and encryption) and it's user friendly to boot.

share|improve this answer

Have a look at the mkfs family of utilities (depending on what you want to format to, you may want mkfs.ext[234], mkfs.vfat, or something else entirely). Bear in mind that you may also have to change the partition type identifier in the partition table using fdisk or similar to make it work across systems.

share|improve this answer

To (re)create a filesystem, use one of the mkfs family of tools. Choose the one based on what filesystem you want; the most common ones are:

  • FAT32 (mkfs.vfat) for maximum compatibility. FAT32 has no notion of file ownership or permissions or symbolic links or many other unixy concepts, just files and directories with many punctuation characters forbidden in file names, and no case sensitivity. The maximum file size is 4GB. Choose this filesystem if you just need to store a bunch of files that aren't larger than 4GB.
  • NTFS for compatibility with Windows. Most basic unixy features are supported. Support for NTFS under operating systems other than Windows tend to be a bit flaky, so choose this filesystem only if you need Windows compatibility and large files.
  • ext4 is the de facto standard Linux filesystem. Choose this if you need unixy features such as symbolic links and permissions.
  • ext2 is an older version of ext4 (lacking features such as a journal and good support for directories with thousands of files) and is supported by more unix systems than ext4 (but don't hope for miracles under Windows). Choose this if you need good support in BSD and at least read-only support under Windows.

You'll need to find out the name of the device that the drive is plugged into. Under Linux, removable drives usually have names like /dev/sda, /dev/sdb, etc. Be sure to pick the right one, or you might erase your hard disk. Under Linux, you can get a list of available drives and their partitions by running cat /proc/partitions; the number in the third column is the size in kilobytes. You can also get an idea of where a drive is plugged in by looking at names in /dev/disk/by-path, and drive models in /dev/disk/by-id. Thumb drives normally have a single partition numbered 1.

On many systems, these tools live in /sbin or /usr/sbin, which is not in the default path for non-root users. Furthermore, you're likely to need to be root to run them.

To create a new filesystem, run the mkfs command on the right device:


Remember to put the right partition number. If you're running Linux and you have a single hard drive and no other connected external drive, the device is usually /dev/sdb1. Thus, the typical command is

sudo mkfs.vfat /dev/sdb1      # be sure to adjust the device name if necessary

mkfs will leave some fragments of old data in place, that will not be erased until they're overwritten by a new file. These fragments can be recovered by looking at the device content, bypassing the filesystem. (There's no guarantee that it will be easy to reconstruct meaningful data from the fragments, so don't hope to use this as an undo for oops-I-formatted-the-wrong-device.) If you want to erase all existing data, run the following command before mkfs:

tee </dev/zero /dev/NAME_OF_DEVICE

Make very very sure that you pick the right device name, as this will erase all data with no hope of recovery.

Note that while this will erase the data with no possibility of recovery by ordinary software means, it may leave traces behind that can be recovered with some electronic work. See Is it enough to only wipe a flash drive once?. The only paranoia-compliant way of erasing data on a flash drive is to have encrypted it in the first place, and destroy all copies of the key.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.