The resize2fs
command is used to resize ext2, ext3, or ext4 file systems. It allows you to increase or decrease the size of a file system on a partition without losing data, making it a valuable tool for managing disk space.
The basic syntax of the resize2fs
command is as follows:
resize2fs [options] [arguments]
-f
: Force the resize operation, even if the file system is mounted.-p
: Print progress information while resizing.-s
: Resize the file system to the size of the underlying block device.-M
: Minimize the size of the file system.-d
: Enable debug output.Here are some practical examples of using resize2fs
:
resize2fs /dev/sda1 20G
This command resizes the file system on /dev/sda1
to 20 gigabytes.
resize2fs /dev/sda1
This command will expand the file system on /dev/sda1
to fill the entire partition.
resize2fs -f /dev/sda1 15G
This command forces the resize of the file system on /dev/sda1
to 15 gigabytes, even if it is mounted.
resize2fs -p /dev/sda1
This command will resize the file system on /dev/sda1
and display the progress of the operation.
-M
option to minimize the file system size, which can help in reclaiming unused space effectively.