How to shrink an LVM Logical Volume

Since shrinking is not supported on these file systems, you cannot reduce the size of a logical volume that houses a GFS2 or XFS file system.

The lvreduce command typically warns about potential data loss and requests confirmation. In some circumstances, such as when the logical volume is inactive, or the —resizefs option is not used, you may not see these confirmation prompts, so you shouldn’t rely on them to prevent data loss. It should be noted that the —test option of the lvreduce command does not examine the file system or test the filesystem; thus, using it does not show whether the operation is safe.

Use the following command to find the name of the logical volume that you want to shrink.

# lvs

The disk must be unmounted to do a lvreduce. Hence this must be done while the disk is idle. To ensure data integrity, perform a filesystem check after that.

# umount /dev/vg0/lv_data
# e2fsck -f /dev/vg0/lv_data

CentOS 5 only: Resize the existing filesystem to 80Gb (ie: 100Gb – 20Gb = 80Gb).

# resize2fs /dev/vg0/lv_data 80G

Centos 6, 7 only: Resize the logical volume.

# lvreduce -r -L 80G /dev/vg0/lv_data

On CentOS 5, use lvreduce as follows.

# lvreduce -L 80G /dev/vg0/lv_data

Mount the LV logical volume as follows.

# mount /dev/vg0/lv_data

There is currently 20G of free space in the volume group. The 20G free space can then be used to build a new logical volume using lvcreate.

Leave a Reply