Before using the mkfs command to create a file system, the fsck command can be used to determine if the partition has a file system type.
fsck -N /dev/sda1
If the partition does have a file system type, something like this should be returned. In this example, the /dev/sda1 partition has the XFS file system.
[/usr/sbin/fsck.xfs (1) -- /boot] fsck.xfs /dev/sda1
The mkfs command can be used to create a filesystem. In this example, the /dev/sda2 partition will be configured to use the ext4 file system.
Or like this.
mkfs -t ext4 /dev/sda2
The mkfs is very simple, and only has a few options. the mke2fs command is more advanced, and includes many possible options.
Following are some of the more popular filesystem types used by Linux.
The -c flag (faster) or -cc flag (slower) can be used to check for bad blocks before creating the file system.
mkfs.ext4 -c /dev/sda2