5.2. Shrinking logical volumes
You can reduce the size of a logical volume with the lvreduce command.
Shrinking is not supported on a GFS2 or XFS file system, so you cannot reduce the size of a logical volume that contains a GFS2 or XFS file system.
If the logical volume you are reducing contains a file system, to prevent data loss you must ensure that the file system is not using the space in the logical volume that is being reduced. For this reason, it is recommended that you use the --resizefs option of the lvreduce command when the logical volume contains a file system.
When you use this option, the lvreduce command attempts to reduce the file system before shrinking the logical volume. If shrinking the file system fails, as can occur if the file system is full or the file system does not support shrinking, then the lvreduce command will fail and not attempt to shrink the logical volume.
In most cases, the lvreduce command 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 --resizefs option is not used.
Note that using the --test option of the lvreduce command does not indicate where the operation is safe, as this option does not check the file system or test the file system resize.
Procédure
To shrink the mylv logical volume in myvg volume group to 64 megabytes, use the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, mylv contains a file system, which this command resizes together with the logical volume.
Specifying the
-sign before the resize value indicates that the value will be subtracted from the logical volume’s actual size. To shrink a logical volume to an absolute size of 64 megabytes, use the following command:lvreduce --resizefs -L -64M myvg/mylv
# lvreduce --resizefs -L -64M myvg/mylvCopy to Clipboard Copied! Toggle word wrap Toggle overflow