USB pen drives are everywhere these days, and for good reason, since they’re dead useful. I use mine with my Linux box, my Powerbook, and various other systems I’ve had cause to stick it in. After a while, my 1 GB drive was only holding a few hundred MB. When I would do an
ls -a on it, I would see several hidden directories, such as .Trashes and .Trash-sarah. Trying to
sudo rm -rf .Trash* would fail out, however, giving complaints of a read-only filesystem. If you’re having such problems, or just really want to make sure your drive is clean, you can reformat it easily in Linux. I reformatted mine using Ubuntu, so the instructions have a slight bias; your mileage may vary. Warning: reformatting your pen drive will delete all its contents.
- Insert your USB drive and let it do its automount thing.
- In a terminal, do
sudo fdisk -lto list your partitions. A list of your partitions will spit out, and your pen drive will probably be in a section like this:
Device Boot Start End Blocks Id System /dev/sda1 1 992 999813+ 6 FAT16
Your pen drive will not necessarily be located at /dev/sda1; if it isn’t, you’ll need to adjust later instructions to point to its location. Be sure you’re working with the right device, because if you use fdisk to delete partitions on, say, your main hard drive, you will delete your hard drive’s contents.
sudo umount /dev/sda1(or whatever the location of your pen drive is) to unmount your pen drive so that you can work with its partitions.
sudo fdisk /dev/sda1to use fdisk to adjust your pen drive’s partitions.
- You’ll now be within fdisk. When my drive was scrambled, I was able to type
pto show the existing partition and
dto delete it. Running through this tutorial to make sure it made sense, I had to type
pto show the partition table,
ato make a partition active,
1to choose the first partition, and
dto delete it. If your situation is like mine, you’ll be asked to choose between several partitions; start from 1 and work through them all. Fdisk complained about the partition not starting in the right spot until I got all the pen drive’s partitions deleted.
nto create a new partition.
pto make it a primary partition.
1to make this the first partition.
- Hit enter to choose the suggested first cylinder.
- Hit enter to choose the suggested last cylinder. This will make the partition take up the maximum space on your pen drive.
ato make this partition active.
1to select making the first partition active.
tto change this partition’s file system type.
6to choose the FAT16 file system.
wto write this new partition table.
- You will be dumped back out to your terminal. Type
sudo mkfs.vfat -F 16 -n USB /dev/sda1to format the first partition.
You can now remove and reinsert your USB drive because you’re done! Try going to its mount location (/media/usbdisk on my machine) and doing
ls -la. You should see something like the following:
total 8 drwxr-xr-x 2 root root 4096 2007-04-18 18:18 . drwxr-xr-x 6 root root 4096 2007-04-19 08:45 .. -rw------- 1 root root 0 2007-04-18 18:18 .created_by_pmount
Other than that, your pen drive should be empty and ready for use. :) Thanks to Pendrivelinux.com for helping me reformat my drive initially through a tutorial for how to install Ubuntu on your pen drive.