I have a USB key they I want to use on a CentOS box. The USB key was previously used on OS X so I want to erase it to make it writable by CentOS.

Can someone help me with the commands I need to run?

I'm guessing it has something to do with fdisk and mkfs (possibly mkfs.ext3). If it makes any difference, the USB key is 32GB.

The disk is located at /dev/sdb.

2 Answers 2


Depending on what level of compatibility you want you can either go for ext3 or the more universal FAT32. To format as FAT32:

$fdisk /dev/sdb
$mkfs.vfat /dev/sdb1 

Or if you want to format for ext3:

$fdisk /dev/sdb
$mkfs.ext3 /dev/sdb1

As an aside if you want to rename the USB pendrive; to rename FAT32:

$sudo mlabel -i /dev/sdb1 ::usb-key

Or for ext3:

$sudo e2label /dev/sdb1 usb-key

For a general look at formatting, check out this howto.


Most USB keys use the FAT format (more precisely FAT32), which is a simple format native to older versions of Windows and almost universally supported.

If you formatted the key using HFS(+) or UFS, and you now want to format it as ext3, first find out if there is a partition on the key. Run ls /dev/sdb*. If this shows only /dev/sdb, there is no partition, so create the filesystem directly onto /dev/sdb. If this shows one partition (probably /dev/sdb1 but it could be a different number), create the filesystem there. If there are several partitions, you can put different filesystems on them, or repartition the disk.

Run file - </dev/sdb1 to check what filesystem is currently on that partition (maybe use a different number or no number as determined above). If you're sure you want to make a new filesystem, run mkfs.ext3 /dev/sdb1. For removable media, you probably don't want any reserved block, so run

mkfs.ext3 -m 0 /dev/sdb1

If your Linux is recent enough, you may want ext4 or btrfs, as they are supposed to be better for flash devices (though I don't know if this applies to low-end flash media as found on USB keys).

But again, there's rarely a reason not to use FAT on a USB key.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .