Reducing a logical volume


Downtime is required for reducing a logical volume

Step 1:

List the logical volume and check the current size. Here i am going to reduce the LV01 to 10G from the current size 30GB

[root@server1 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
LV01 VG01 -wi-ao—- 30.00g
LV02 VG01 -wi-a—– 40.00m

 

Step 2:

Unmount the logical volume

[root@server1 ~]# df -h /mount_point/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VG01-LV01 30G 45M 28G 1% /mount_point
[root@server1 ~]# umount /mount_point/

 

Step 3:

Run e2fsck on the logical volume

[root@server1 ~]# e2fsck -f /dev/mapper/VG01-LV01
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/VG01-LV01: 11/1966080 files (0.0% non-contiguous), 167453/7864320 blocks

 

Step 4:

Run resize2fs on the logical volume with size we want to reduce .Here it is 10GB

[root@server1 ~]# resize2fs /dev/mapper/VG01-LV01 10G
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/mapper/VG01-LV01 to 2621440 (4k) blocks.
The filesystem on /dev/mapper/VG01-LV01 is now 2621440 blocks long.

 

Step 5:

Reduce the logical volume by running lvreduce

[root@server1 ~]# lvreduce -L 10G /dev/mapper/VG01-LV01
WARNING: Reducing active logical volume to 10.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LV01? [y/n]: y
Reducing logical volume LV01 to 10.00 GiB
Logical volume LV01 successfully resized

 

Step 6:

Verify the logical volume size

[root@server1 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
LV01 VG01 -wi-a—– 10.00g
LV02 VG01 -wi-a—– 40.00m

 

Step 7:

Mount the logical volume

[root@server1 ~]# mount -a
[root@server1 ~]# df -h /mount_point/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VG01-LV01 9.8G 37M 9.2G 1% /mount_point