Just creating partitions isn't enough to make them useful in Linux. To make them useful, you must create a filesystem on the partition. (A task that's also sometimes called "formatting" a partition.) Linux uses the mkfs program to accomplish this task. This tool has the following syntax:
mkfs is actually just a front-end to tools that do the real work for specific filesystems, such as mke2fs (also known as mkfs.ext2). You can call these tools directly if you prefer, although their syntax may vary from that of mkfs.
The meanings of the mkfs parameters are as follows:
-V This option causes mkfs to generate verbose output, displaying additional information on the filesystem-creation process.
-t fstype You specify the filesystem type with this option. Common values for fstype include ext2 (for ext2fs), msdos (for FAT), and minix (for Minix).
options You can pass filesystem-specific options to the utility. Most underlying filesystem creation tools support -c (to perform a low-level disk check to be sure the hardware is sound) and -v (to perform a verbose creation).
device This is the name of the device on which you want to create the filesystem, such as /dev/sda5 or /dev/fd0. You should not normally specify an entire hard disk here (such as /dev/sda or /dev/hdb). One exception might be if it's a removable disk, but even these are often partitioned.
blocks This is the size of the filesystem in blocks (usually 1024 bytes in size). You don't normally need to specify this value, since mkfs can determine the filesystem size from the size of the partition.
Depending upon the size and speed of the disk device, the filesystem creation process is likely to take anywhere from a second or less to a minute or two. If you specify a filesystem check (which is often a good idea), this process can take several minutes, or possibly over an hour. Once it's done, you should be able to mount the filesystem and use it to store files.
The filesystem creation process is inherently destructive. If you accidentally create a filesystem in error, it will be impossible to recover files from the old filesystem unless you're very knowledgeable about filesystem data structures, or you can pay somebody with such knowledge. Recovery costs are apt to be very high.
As noted earlier, mkfs is just a front-end to other utilities. These are sometimes called directly instead. For instance, the usual method of formatting a ReiserFS partition is to use the mkreiserfs utility.
Was this article helpful?