Formatting a usb drive in linux

So you’ve got a USB drive, and you need to reformat it. You can do this all quite easily on the command line using the fdisk utility.

First, get the device location. This will be something like /dev/sdd. You want the location of the device, not a partition on the device ie: /dev/sdd instead of /dev/sdd1.

The instructions below work for both FAT32 (Windows) and ext2 (Linux) – replace /dev/sdd with your device’s address:

fdisk /dev/sdd
p (print partitions)
d (delete partitions)
p (print partitions)
n (new partition)
p (primary partition)
(press enter to use defaults for all options here)
t (specify file system type)
b (FAT32) or 83 (Linux)
w (write and exit)

Now that we’ve set the partitions, we need to create the actual filesystem. This is a one line command:

ext2: mkfs -t ext2 /dev/sdd1
FAT32: mkdosfs /dev/sdd1

And you’re done! Your USB stick is now ready to use.

Leave a Reply

Your email address will not be published.