How to Create a New Ext4 File System in Linux?

Creating a new Ext4 file system in Linux involves formatting a partition with the Ext4 file system type. This is essential when adding new storage or repurposing existing partitions. In this tutorial, we'll explore how to identify available file systems, examine current partitions, and format a partition with Ext4.

Available Filesystem Types

First, let's check what file system tools are available on your system. The following command lists all the file system creation utilities ?

$ ls -1 /sbin/mkfs*
/sbin/mkfs
/sbin/mkfs.bfs
/sbin/mkfs.cramfs
/sbin/mkfs.ext2
/sbin/mkfs.ext3
/sbin/mkfs.ext4
/sbin/mkfs.ext4dev
/sbin/mkfs.fat
/sbin/mkfs.minix
/sbin/mkfs.msdos
/sbin/mkfs.ntfs
/sbin/mkfs.vfat

The presence of /sbin/mkfs.ext4 confirms that Ext4 formatting tools are available.

Examining Current Partitions

Before creating a new Ext4 partition, examine the current disk layout to identify available space or existing partitions ?

$ sudo fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x06807e05

Device     Boot    Start        End    Sectors   Size   Id   Type
/dev/sda1  *        2048   33554431   33552384    16G   83   Linux
/dev/sda2       33556478   41940991    8384514     4G    5   Extended
/dev/sda5       33556480   41940991    8384512     4G   82   Linux swap / Solaris

Creating a New Partition

To create a new partition, use fdisk with the disk device. First, let's view available partition types ?

$ sudo fdisk /dev/sda
Command (m for help): l
 0  Empty               24  NEC DOS             81  Minix / old Lin     bf  Solaris
 1  FAT12               27  Hidden NTFS Win     82  Linux swap / So     c1  DRDOS/sec (FAT-
 2  XENIX root          39  Plan 9              83  Linux               c4  DRDOS/sec (FAT-
 3  XENIX usr           3c  PartitionMagic      84  OS/2 hidden or      c6  DRDOS/sec (FAT-
 4  FAT16 <32M          40  Venix 80286         85  Linux extended      c7  Syrinx
 5  Extended            41  PPC PReP Boot       86  NTFS volume set     da  Non-FS data
 6  FAT16               42  SFS                 87  NTFS volume set     db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT     4d  QNX4.x              88  Linux plaintext     de  Dell Utility
 8  AIX                 4e  QNX4.x 2nd part     8e  Linux LVM           df  BootIt

Choose option n to create a new partition, then follow the prompts to specify size and location ?

Command (m for help): n
Partition type:
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (2048-41943039, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-33554431, default 33554431): +2G

Created a new partition 3 of type 'Linux' and of size 2 GiB.

Write the changes to disk by pressing w.

Formatting with Ext4

Now format the new partition with the Ext4 file system using mkfs.ext4 ?

sudo mkfs.ext4 /dev/sda3
mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: f47ac10b-58cc-4372-a567-0e02b2c3d479
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

Verifying the New File System

Verify the new Ext4 partition was created successfully ?

$ sudo blkid /dev/sda3
/dev/sda3: UUID="f47ac10b-58cc-4372-a567-0e02b2c3d479" TYPE="ext4"

Mounting the New Partition

Create a mount point and mount the new Ext4 partition ?

sudo mkdir /mnt/newdrive
sudo mount /dev/sda3 /mnt/newdrive
df -h /mnt/newdrive
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       2.0G   24K  1.9G   1% /mnt/newdrive

Conclusion

Creating an Ext4 file system involves partitioning the disk with fdisk and formatting with mkfs.ext4. Always verify the partition before formatting and ensure you have backups of important data before making partition changes.

Updated on: 2026-03-15T17:35:41+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements