Linux - resize2fs - ext2/ext3 file system resizer

About

The resize2fs program will resize ext2 or ext3 file systems. It can be used to enlarge or shrink an unmounted file system located on device. If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel supports on-line resizing. (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 only.).

The resize2fs program does not manipulate the size of partitions.

Syntax

resize2fs  [  -d  debug-flags ] [ -S RAID-stride ] [ -f ] [ -F ] [ -p ] device [ size ]

The size parameter specifies the requested new size of the filesystem. If no units are specified, the units of the size parameter shall be the filesystem blocksize of the filesystem. Optionally, the size parameter may be suffixed by one of the following the units designators: âsâ, âKâ, âMâ, or âGâ, for 512 byte sectors, kilobytes, megabytes, or giga- bytes, respectively. The size of the filesystem may never be larger than the size of the partition. If size parameter is not specified, it will default to the size of the partition.

OPTIONS:

  • -d debug-flags

Turns on various resize2fs debugging features, if they have been compiled into the binary. debug-flags should be computed by adding the numbers of the desired features from the following list:

* 1    - Print out all disk I/O
  * 2    - Debug block relocations
  * 8    - Debug inode relocations
  * 16   - Debug moving the inode table

  • -S RAID-stride

The resize2fs program will heuristically determine the RAID stride that was specified when the filesystem was created. This option allows the user to explicitly specify a RAID stride setting to be used by resize2fs instead.

  • -p

Prints out a percentage completion bars for each resize2fs operation, so that the user can keep track of what the program is doing.

  • -f

Forces resize2fs to proceed with the filesystem resize operation, overriding some safety checks which resize2fs normally enforces.

  • -F

Flush the filesystem devices buffer caches before beginning. Only really useful for doing resize2fs time trials.

How to enlarge a filesystem ?

If you wish to enlarge a filesystem, you must first make sure you can expand the size of the underlying partition first. This can be done using fdisk by :

  • deleting the partition and recreating it with a larger size
  • or using lvextend, if you are using the logical volume manager lvm.

When recreating the partition, make sure you create it with the same starting disk cylinder as before! Otherwise, the resize operation will certainly not work, and you may lose your entire filesystem. After running fdisk, run resize2fs to resize the ext2 filesystem to use all of the space in the newly enlarged partition.

How to shrink a partition ?

If you wish to shrink an ext2 partition, first use resize2fs to shrink the size of filesystem. Then you may use fdisk to shrink the size of the partition. When shrinking the size of the partition, make sure you do not make it smaller than the new size of the ext2 filesystem!







Share this page:
Follow us:
Task Runner