man ext2resize (Administration système) - GNU ext2 filesystem resizer

NAME

ext2resize - GNU ext2 filesystem resizer

SYNOPSIS

ext2resize [-d] [-f] [ -q] [-u] [-v] [-V] device [size[b|K|M|G|T]]

DESCRIPTION

The ext2resize tool resizes an unmounted ext2 or ext3 file system. It enlarges or shrinks the file system located on device (partition, loop device, logical volume, ...) so that it will have size ext2 filesystem blocks. If the size parameter is not specified, the filesystem will be resized to fill the given device. The size parameter may have one of the optional modifiers b, K, M, G, or T which means the size parameter is given in 512-byte blocks, kilo-, mega-, giga-, or terabytes respectively.

The ext2resize program does not manipulate the size of the device. If you wish to enlarge a filesystem, you must make sure you expand the underlying device first. This can be done using fdisk(8) for partitions, by deleting the partition and recreating it with a larger size (assuming there is free space after the partition in question). Make sure you re-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. Logical Volumes can be extended with lvextend(8) prior to growing a filesystem, or after shrinking it. Alternately, the e2fsadm(8) tool can be used to combine the operations of resizing the Logical Volume and the filesystem into one step.

If you wish to shrink an ext2 or ext3 partition, first use ext2resize to shrink the file system. You may then use fdisk(8) or lvreduce(8) to shrink the device. When shrinking the size of the device, make sure you do not make it smaller than the reduced size of the ext2 filesystem. If you are not sure of the exact device size, shrink the filesystem slightly more than desired, shrink the device, and then run ext2resize again to increase the filesystem to fill the new device size.

-d, --debug
Turns on various debugging messages, normally only useful if you are working on a problem.
-f, --force
Force, do not perform sanity checks. Use with EXTREME care, you are on your own.
-u, --unsafe
Do not flush the device's buffer cache during the resize operation.
-q, --quiet
Do not print anything but error messages.
-v, --verbose
Turn on extra progress status messages.
-V, --version
Print the version number and exit.

RETURN VALUES

0 Resizing successful.

1 Error in command line.
2 Error during resize operation.

EXAMPLES

The following example shows how to test ext2resize on a loop device. First a file of 10MB is created which is mounted on the loop device. Then an 5MB ext2 filesystem is created on the loop device, after mounting its size is verified. Before extending unmounting is necessary, when the size parameter is not specified the filesystem is extended to fill the loop device.

dd if=/dev/zero of=/tmp/file bs=1k count=10240

losetup /dev/loop0 /tmp/file

mke2fs /dev/loop0 5120

mkdir /mnt/test

mount /dev/loop0 /mnt/test

df /mnt/test

umount /mnt/test

ext2resize /dev/loop0

mount /dev/loop0 /mnt/test

df /mnt/test

For shrinking the loop device we need to unmount it first, then run ext2resize with a size parameter, in this case 8MB.

umount /mnt/test

ext2resize /dev/loop0 8M

mount /mnt/test

df /mnt/test

WARNING

Note that resizing a filesystem is inherently dangerous and may corrupt filesystems, although no errors resulting in data loss have ever been reported to the author. Use with caution. Backups are always a good idea, because your disk may fail at any time, you delete files by accident, or your computer is struck by a meteor.

AUTHOR

GNU ext2resize was written by Lennert Buytenhek <buytenh@gnu.org> with the help of volunteers around the net. This man page was originally written by Joey Hess <joey@kitenet.net>, and Dirk de Rycke significantly improved that version.

COPYRIGHT

GNU ext2resize is (C) Copyright 1998, 1999 by Lennert Buytenhek, and 2000, 2001 Andreas Dilger, and may be distributed under the terms of the GNU General Public License.

SEE ALSO