How to reduce the size of LVM partitions in Linux Easily

This post will show you How to reduce the size of LVM partitions in Linux Easily.


How to reduce the size of LVM partitions in Linux Easily


In this post, We explain you how to reduce the LVM partition size in Linux. We may come across in a situation to reduce the LVM Partition in Linux.


Assume that, we wanted to reduce the /data by 2GB. But make sure that you have free physical extents of 2Gb, Else we need to move the used extents from one PV to other PV.

Refer this link to know how to remove physical volume in linux., Hope you have free physical extends of 2Gb to reduce the logical volume.

[root@linux ~]# df -h /data
Filesystem                            Size       Used    Avail     Used%      Mounted on
/dev/mapper/vg01-lvol0         10G        5.0G    4.9G      50%        /data

Step1 : Umount the filesystem


[root@linux ~]#  umount  /data

Step2 : Check the filesystem for errors using e2fsck command


[root@linux ~]# e2fsck -f /dev/mapper/vg01-lvol0
e2fsck 1.41.12 (17-May-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-lvol0: 10/770640 files (0.0% non-contiguous), 2446686/3084288 blocks

Step3 : Reduce the volume size of /data


[root@linux ~]# resize2fs /dev/mapper/vg01-lvol0 8G
resize2fs 1.41.12 (17-May-2013)
Resizing the filesystem on /dev/mapper/vg01-lvol0 to 2021440 (4k) blocks.
The filesystem on /dev/mapper/vg01-lvol0 is now 2021440 blocks long.

Step4 : Reduce the size in LVM using lvreduce command


[root@linux ~]# lvreduce  -L 8G /dev/mapper/vg01-lvol0
WARNING: Reducing active logical volume to 8.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvol0? [y/n]: y
Reducing logical volume Lvol0 to 8.00 GiB
Logical volume Lvol0 successfully resized

Step5 : Mount the file system and verify the size


[root@linux ~]# mount /home
[root@linux ~]# df -h /home
Filesystem                            Size       Used    Avail     Used%      Mounted on
/dev/mapper/vg01-lvol0          8G         5.0G    2.9G      70%        /data


Hope this post helped you to reduce the size of LVM partitions in Linux Easily.


Related Content on Linux might be useful to you to improve your Linux Skills.


Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.

Post a Comment

0 Comments