The resize2fs command is used to enlarge or shrink an ext2/3/4 file system on a device. You can enlarge a mounted file system, but you must unmount the file system before you can shrink it. You can specify the desired size of the file system in order to either enlarge or shrink it. If you don’t specify a size, the file system will be resized to the same size as the partition.

It’s important to note that resize2fs does not resize partitions, only the file system. You must use a command like fdisk or an LVM tool to expand the size of the partition/ volume first in order to then enlarge the file system.

Syntax

The syntax of the resize2fs command is:

# resize2fs [options] {device/file system name} [desired size]

resize2fs Command Examples

1. To resize a recently extended file system:

# resize2fs /dev/mapper/VG02-LV05 

2. To forcefuly resize the file system:

# resize2fs -f /dev/mapper/VG02-LV05 

3. To flush the filesystem device’s buffer caches:

# resize2fs -F /dev/mapper/VG02-LV05 

4. To shrink the filesystem to the minimum size:

# resize2fs -M /dev/mapper/VG02-LV05 

5. To prints out a percentage completion bars for each resize2fs operation:

# resize2fs -p /dev/mapper/VG02-LV05 

6. To Print the minimum size of the filesystem and exit:

# resize2fs -P /dev/mapper/VG02-LV05