To format a disk in Linux, first it should be partitioned, this how-to assumes you have already partitioned the hard drive, if you need to to partition your disk, read the how to partition a Linux disk

Linux can format in various file systems, here we will use only ext2, ext3 or swap, which are some of the most used file systems in Linux.

Lets suppose the drive you need to format is: /dev/hda1

To format it using the filesystem ext2, enter

sudo mkfs -t ext2 /dev/hda1

If it is ext3 what you want enter:

sudo mkfs -t ext3 /dev/hda1

you can also use the mkfs.ext2, mkfs.ext3 or mkswap to format directly in the file system you want.