LPIC 104.1 Create partitions and filesystems

Weight: 2

Key Knowledge Areas:

  • Manage MBR partition tables
  • Use various mkfs commands to create various filesystems such as:
  • ext2/ext3/ext4
  • XFS
  • VFAT
  • Awareness of ReiserFS and Btrfs
  • Basic knowledge of gdisk and parted with GPT

Terms and Utilities:

  • fdisk
  • gdisk
  • parted
  • mkfs
  • mkswap

Partition Tools

A key concept with fdisk is that your changes are not written to disk until you tell it to save.
fdisk /dev/sda
fdisk -l
print current disk partition information

gdisk As fdisk initially only worked with MBR partitions, gdisk was created to work with GPT(GUID Partition Tables).

parted doesn't set partition flag as Linux doesn't care about this.
mkpart is the command to create partition in parted, you can specify all the parameters on one line.

A graphical partition manager, it can resize filesystem and partition table.


A filesystem is an organizing construct that acts like a database or hierarchical structure that contains directories and files in a partition. The filesystem is what helps Linux lay out the files into their blocks on disk and to find those blocks later.

Directory entries mapping a filename to an inode, and a directory itself is just a list of directory entries for the files and sub-directories.

The filesystem has two structures on it. The first is the data blocks that contain the files and directories; the second is the inode table that has all the file metadata.

The Btrfs filesystem will possibly be next generation filesystem. It main feature supports copy-on-write.

Superblocks The superblock contains information about the filesystem, such as filesystem size, inode statistics, and when the filesystem was last checked by a utility like the fsck command.

Inodes and Files Each file has a corresponding inode.
Everything descriptive about the file except the actual filename is stored in the inode.

Inodes and Directories
df -i command shows inode utilization.

Creating Filesystems

mkfs -t ext4 /dev/sdb1 is equivalent to mkfs.ext4 /dev/sdb1 which will format partition with ext4 filesystem.

All below 3 commands will create ext3 filesystem for you:

mkfs –t ext3 device  
mkfs.ext3 device  
mke2fs –j device  

# mkfs.ext3 -b 4096 -m 2 -L data -O sparse_super /dev/sdb1

This command creates an ext3 filesystem on the /dev/sdb1 with a 4,096 block size, a reserved block percentage of 2%, a volume label of data , and the sparse_super option for fewer superblock copies for the disk

-m reserved-blocks-percentage
Specify the percentage of the filesystem blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such as sys-logd(8), to continue to function correctly after non-privileged processes are prevented from writing to the filesystem. The default percentage is 5%.

Makes a partition or file into swap space.