resize2fs
Resize ext2/3/4 file systems
TLDR
Automatically resize a filesystem
Resize the filesystem to a size of 40G, displaying a progress bar
Shrink the filesystem to its minimum possible size
SYNOPSIS
resize2fs [ -fFpPMd ] [ -s new_size ] device
resize2fs -check device
resize2fs -C progress_flags device
PARAMETERS
-f
Forces a resize even if the file system is not clean.
-F
Flushes the file system device's write caches before beginning.
-p
Shows a percentage completion bar during the resize operation.
-P
Print the planned changes to the file system.
-M
Shrink the file system to the minimum size.
-d debug-flags
Turn on debugging output. Use "-d help" to get list of flags.
-s new_size
Specifies the new size of the file system in bytes. If no units are specified, the units are assumed to be in kilobytes. The size may have a K, M, or G suffix, which means kilobyte, megabyte, or gigabyte, respectively.
-C progress_flags
Configure the progress bar.
device
The device where the file system resides (e.g., /dev/sda1).
-b block_size
Sets the block size of the file system (rarely used).
DESCRIPTION
The resize2fs command is used to resize ext2, ext3, or ext4 file systems. It can be used to both enlarge and shrink file systems located on a device. The command can operate online (while the file system is mounted) but only for enlarging the file system. Shrinking the file system requires it to be unmounted. When growing a file system, the new size can be specified explicitly, or the utility can determine the maximum safe size. It is essential to back up your data before shrinking a file system, as data loss is possible if the operation is interrupted or encounters errors. When resizing a file system, it's often necessary to resize the underlying partition as well, using utilities such as fdisk, parted, or LVM tools.
CAVEATS
Shrinking a file system can be risky and may lead to data loss if the operation fails. Always back up your data before shrinking a file system. Do not interrupt the resize2fs process.
ONLINE RESIZING
Online resizing allows you to resize a mounted ext4 file system. However, only enlarging the filesystem is supported while it is mounted.
MINIMUM SIZE
Using the -M option attempts to shrink the file system to its minimum possible size. This is useful for preparing an image of the file system for distribution.
HISTORY
resize2fs is part of the e2fsprogs package, which provides utilities for managing ext2, ext3, and ext4 file systems. It has been under active development for many years, evolving to support new features and improvements in the ext file system family. The tool's origin traces back to the early days of Linux, aligning with the development and adoption of the ext file systems. It's been a crucial tool for system administrators to efficiently manage storage capacity.