How to format a partition in Linux. This is very easy.

Formatting a partition in Linux is very easy when you use the mkfs command. In this example I am formatting a 35 gigabyte partition with an EXT4 file-system. I am intending to try out a Linux From Scratch build and I want to have a dedicated partition to build this on.

jason@eyjafjallajkull:~/Documents$ sudo mkfs.ext4 /dev/sdb2 
mke2fs 1.42.12 (29-Aug-2014)
/dev/sdb2 contains a ext4 file system
	last mounted on /media/jason/3850a06f-d55d-4af6-b4ac-918e69313722 on Fri Jan 16 11:27:37 2015
Proceed anyway? (y,n) y
Creating filesystem with 8447998 4k blocks and 2113536 inodes
Filesystem UUID: 7ebd3547-7d2b-4d58-a52b-4f7968d14050
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624
 
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This command will tell you if the partition was mounted before and ask if you really want to go ahead with this. Of course we do so say yes and the new file-system will be created.

And this is the content of this new file-system.

root@eyjafjallajkull:/mnt/LFS# ls -hula
total 20K
drwxr-xr-x 3 root root 4.0K Jan 16 11:31 .
drwxr-xr-x 4 root root   28 Jan 16 11:38 ..
drwx------ 2 root root  16K Jan 16 11:30 lost+found

No comments have been made. Use this form to start the conversation :)

Leave a Reply