FreeKB - Linux Commands mkfs (create a file system)
Linux Commands - mkfs (create a file system)

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.

mkfs.ext4 /dev/sda2

 

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.

  • ext2 (second extended file system)
  • ext3 (third extended file system)
  • ext4 (fourth extended file system)
  • xfs (extended file system)
  • lvm (logical volume)
  • raid

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

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 928e8 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |