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.
- Do
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. - Do
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 anddto delete it. Running through this tutorial to make sure it made sense, I had to typepto show the partition table,ato make a partition active,1to choose the first partition, anddto 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. - Type
nto create a new partition. - Choose
pto make it a primary partition. - Type
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.
- Type
ato make this partition active. - Choose
1to select making the first partition active. - Type
tto change this partition’s file system type. - Type
6to choose the FAT16 file system. - Type
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.
10 Comments
Oh, I’ve been wondering how to get rid of those hidden .Trash directories that Ubuntu likes to stick on my USB stick (I’ve never heard them called pen drives!). I always just booted into Windows and deleted all of the trash files, but now that I don’t have to go throough the hassle of Windows, that’s nice.
You can configure Nautilus not to create the .Trash folder – see http://ubuntu.wordpress.com/2006/09/13/no-trash-on-external-usb-drives/
Awesome Steve, thanks! Now I can avoid future reformats.
so why do you delete/recreate partition before formating? surely a simple mkfs.vfat… would do?
Well you can also use gparted
sudo apt-get install gparted
gparted
that’s it
hi
im looking for mp4 player, its actull size showing 1.98 that mean 2gb but its formated to 475mb i want to remove this partition and make the partition to 1gb if possible tell me doing in windows, i try the things u mentioned steps ..
its partitoned to 475mb i want to delete this and extend its partition, 2gb mp4 player supports amv formate video file player..mp3,fm,pic book,games etc.if get solution plz mail me to dvinod.eluru@gmail.com
This is exactly what I have found. Could you tell me how I reformat a stick when I use a mac OS X?
Many thanks
You should be able to use the same technique as above, because when I do
which fdiskon my Powerbook, it tells me/usr/sbin/fdisk, so fdisk is available on OS X.Excellent step by step instrutions. Worked great for me. Thank you!