Linux Commands

How To Resize the EXT4 Partition

There are various file systems in Linux that have specific and fixed sizes. Although there are some myths that it is impossible to resize a mounted filesystem, there are some commands to resize them.

However, many beginners don’t know about these commands and may get errors while resizing EXT4. In this tutorial, we will explain the complete method to resize the EXT4 in Linux.

How To Resize the EXT4 Partition

You can use the resize2fs to increase the size of the EXT4 file system. This command can increase the size of unmounted EXT2, EXT3, and EXT4 filesystems. Following is the syntax of the resize2fs command:

resize2fs {mount/dev} size

In the previous syntax, size is the new size for the EXT4 filesystem. This parameter, in general, is a block size. Let’s take an example where we want to resize the EXT4, which is available in the /dev/sda3. First, run the following command to display the details:

df -h

You can also use the lsblk command to get in-depth details about the location of the EXT4 file system:

lsblk -f

Now we have the details about the size of the current file system so let’s run the following command to resize EXT4:

resize2fs /dev/sda3

As you can see in the previous image, the terminal displays that the file system is already 4k blocks long. That’s why you can use the -d (debug) flag that contains the following options:

Options
2 Debug relocation of blocks
4 Debug relocation of inodes
8 Debug the inode table movings
16 Print the information timing
32 Debug the calculation of minimum filesystem size (-M)

For instance, let’s debug relocations of blocks using the -d option in the resize2fs command:

resize2fs /dev/sda3

If you want to know more about the resize2fs command, you can run the following command:

resize2fs

Here are the details about these additional flags:

Flags Description
-f Forces to proceed with the resize operation of filesystems and safety checks overriding
-F Flushes the filesystem’s current device’s buffer caches
-M Decreases the file system’s minimum size
-p Prints the percentage completion bars for each resize2fs operation
-P Prints the filesystem’s minimum size
-S Users can specify the RAID stride settings

Conclusion

In this tutorial, we have explained everything you need to know about methods to resize the EXT4. We used the resize2fs command to resize the EXT4 partitions without errors. Moreover, we have also explained the additional options you can use to increase or decrease the EXT4 partitions.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.