It’s possible to reduce the size of a logical volume without any data loss occurring.
The first step is to check the existing size of the logical volume:
[root@slave ~]# lvdisplay /dev/myvg/mylv --- Logical volume --- LV Path /dev/myvg/mylv LV Name mylv VG Name myvg LV UUID K31i4c-mJmI-mNhJ-CvkB-c38D-7wCd-I2erTM LV Write Access read/write LV Creation host, time slave, 2014-10-13 20:01:22 -0400 LV Status available # open 1 LV Size 4.00 GiB Current LE 1024 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
The current size is 4 GB, although we would like to change the size to 2 GB.
As a cautious measure, run fsck on the logical volume to ensure that the file system is in a consistent state.
[root@slave ~]# fsck /dev/myvg/mylv
We will now resize the file system to 2 GB.
[root@slave ~]# resize2fs /dev/myvg/mylv 2G
The final step is to reduce the logical volume using lvreduce.
[root@slave ~]# lvreduce /dev/myvg/mylv -L 2G WARNING: Reducing active and open logical volume to 2.00 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce mylv? [y/n]: y Reducing logical volume mylv to 2.00 GiB Logical volume mylv successfully resized
Verify the new logical volume size using lvdisplay.
[root@slave ~]# lvdisplay /dev/myvg/mylv --- Logical volume --- LV Path /dev/myvg/mylv LV Name mylv VG Name myvg LV UUID K31i4c-mJmI-mNhJ-CvkB-c38D-7wCd-I2erTM LV Write Access read/write LV Creation host, time slave, 2014-10-13 20:01:22 -0400 LV Status available # open 1 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2