Formatting a partition in Linux
mkfs(make file system) or mke2fs(make 2min file system) are the commands used for formatting a partition in Linux. If a partition has previously formatted, you need to use mkfs command, and Linux will reformat the partition to same filesystem. Or you can add “-t” parameter in order to specify the type of filesystem to be built(ext2/3,vfat, reiserfs) or “-c” for checking the bad blocks before formatting.
For example; the following commands format the /dev/sda2 partitions to noted filesystems:
# mkfs -t ext2 /dev/sda2
# mkfs -t ext3 /dev/sda2
# mkfs -t vfat /dev/sda2
# mkfs -t reiserfs /dev/sda2
Or you can use:-
# mkfs -j /dev/sda2
(-j creates a journal with ext3 filesystem)
Or,
mke2fs -O journal_dev [ -b block-size ] [ -L volume-label ] [ -n ] [ -q ] [ -v ] external-journal [ blocks-count ]
and mkswap command is used to format the Linux swap space. For example, if you want /dev/sda3 as a swap partition, the command is
# mkswap /dev/sda3

