[CentOS] How to format a USB drive?

Thu Jun 2 15:52:53 UTC 2011
Lamar Owen <lowen at pari.edu>

On Thursday, June 02, 2011 11:27:00 AM Todd Cary wrote:
> I have a usb drive, /media/disk and I want to reformat it.  There 
> are several questions that come up:

Ok, so it's mounted on /media/disk; you'll first have to determine what the actual device is (/dev/sdb or similar).

> How can I determine the current format?

The mount command will give you this.  Example:
# mount
/dev/mapper/vg_backup670-lv_root on / type ext3 (rw)
...

The / filesystem is mounted as type ext3.  Look for your /media/disk in the list; this will also give you the actual device name.

> Do I use the mkfs command?

You can partition the USB stick, and if you have a U3-capable stick, like some SanDisk Cruzers, you can re-allocate portions to the emulated CD and the writeable filesystem using the u3-tool package (google it; it's on SourceForge, I think, and I've used it to put a 1.4GB NST ISO onto the CD portion of a SanDisk, as well as enlarging the CD portion to 1.4GB in the first place....)...

On non-U3 sticks, and on the hard disk portion of a U3-capable stick, partitioning is done like any other hard disk.  Then you can mkfs like you would any other hard disk.  There are filesystems that are easier on flash drives than other types; wikipedia will help you there.  

You will need to umount /media/disk first.

In C6 you'll be able to do all of this in the GUI with gnome-disk-utility, aka palimpsest, and do it quickly and smoothly.  (I have a box with RHEL6 on it, and the RHEL6 version of palimpsest works very similarly to the Fedora 12+ version, and it has some very nice features, all in a well-integrated interface).