5.4.15. Shrinking Logical Volumes
--resizefsoption of the
lvreducecommand when the logical volume contains a file system. When you use this option, the
lvreducecommand attempts to reduce the file system before shrinking the logical voume. If shrinking the file sytem fails, as can occur if the file system is full or the file system does not support shrinking, then the
lvreducecommand will fail and not attempt to shrink the logical volume.
lvreducecommand warns about possible data loss and asks for a confirmation. However, you should not rely on these confirmation prompts to prevent data loss because in some cases you will not see these prompts, such as when the logical volume is inactive or the
--resizefsoption is not used.
--testoption of the
lvreducecommand does not indicate where the operation is safe, as this option does not check the file system or test the file system resize.
lvol1in volume group
vg00to be 64 megabytes. In this example,
lvol1contains a file system, which this command resizes together with the logical volume. This example shows the output to the command.
lvreduce --resizefs -L 64M vg00/lvol1fsck from util-linux 2.23.2 /dev/mapper/vg00-lvol1: clean, 11/25688 files, 8896/102400 blocks resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on /dev/mapper/vg00-lvol1 to 65536 (1k) blocks. The filesystem on /dev/mapper/vg00-lvol1 is now 65536 blocks long. Size of logical volume vg00/lvol1 changed from 100.00 MiB (25 extents) to 64.00 MiB (16 extents). Logical volume vg00/lvol1 successfully resized.
lvreduce --resizefs -L -64M vg00/lvol1