Formatting a partition from command line

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

Formatting a new partition from the command line is pretty straight forward.
I do it quite often when playing working with LVM.

So, long story short, format the partition (to ext4 in this example)

mkfs.ext4 /dev/sdxy

Change the "reserved-blocks-percentage" for data partition (optional).
Normally the default is 5%. If it's a file system partition, don't set it to 0 like I'm doing now.

tune2fs -m 0 /dev/sdxy

Check the file system just created

fsck.ext4 -fy /dev/sdxy

and mount it.

mount /dev/sdxy /wherever/I/want

That's all. Remember to add the partition to the fstab file in case you want to mount it at boot.

Leave a Reply

Your email address will not be published.