mkfs

Creates a filesystem in any device attached to your Linux box.

You should use it with care as it will erase all the data on the device on which it acts, so be sure you have backup of your data, and you use it in the right way.

Usage

mkfs [options] device

Where device is the name of the device you want to create a file system on. Usually /dev/XXX, you can use also the mountpoint of the device if it is mounted.

Here is the dangerous part, pick the right device name, if you fail doing this you can destroy your main working disk.

Options

-t fstype
Is the type of the file system you want to create on the given device, it can be, ext2, ext3, msdos, vfat, etc.
-V
Enables the verbose mode

This command should be run as root, or with root permissions

Example:

mkfs -t ext3 /dev/hda1

There are also type specific command, which in fact are called by mkfs; these are:

mke2fs mkfs.ext3 mkfs.msdos mkfs.vfat

use:

man mke2fs man mkfs.ext3 man mkfs.msdos man mkfs.vfat

for the type specific options available. Note: mke2fs and mkfs.ext3 are usually the same file.