How To Reduce LVM Partition Size Linux Step by Step Guide

In this Article I am going to explain you, how to reduce LVM Partition Size Linux Step by Step. To Understand better about LVM and Creating LVM Partition read previous article What Is Local Volume Manager and How To Create Logical Volume Partition

Resize the LVM (/lvm1) to 100MiB ( size may very between 80MB to 130MB ) due to partition reservation for internal file system use.

How To Reduce LVM Partition Size Linux

You can’t simple reduce LVM partition size, you have to do below process before proceeding to reduce LVM

  • Shutdown applications which are hosted in /lvm1 path
  • Take Complete LVM Backup
  • Unmount /lvm1 file system
  • Hashout /etc/fstab entry (To avoid unforeseen mount issues)
  • File System must be EXT2,EXT3 Or EXT4. XFS file system can’t be reduced

Steps are below to reduce Linux LVM

[root@ArkIT-Serv ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 38G 6.8G 31G 19% /
/dev/sda1 xfs 497M 124M 373M 25% /boot
/dev/mapper/VG0-lv1 ext4 988M 2.6M 919M 1% /lvm1

From 1GB we are going to reduce to 100MB
Like shown below comment fstab entry

[root@ArkIT-Serv ~]# cat /etc/fstab |grep lvm1
#/dev/VG0/lv1 /lvm1 ext4 defaults 0 0

Un-Mount LVM mount point to avoid data loss

#umount /lvm1

Run File system check forcefully to fix inode and block level errors

[root@ArkIT-Serv ~]# e2fsck -f /dev/VG0/lv1
e2fsck 1.42.9 (28-Dec-2013)
Pass1: Checking inodes, blocks, and sizes
Pass2: Checking directory structure
Pass3: Checking directory connectivity
Pass4: Checking reference counts
Pass5: Checking group summary information
/dev/VG0/lv1: 11/65280 files (0.0% non-contiguous), 8843/261120 blocks

As per above output no errors found, ready to go ahead with Reduce LVM Size. To Reduce LVM we have to go in reverse way that first reduce file system on particular LVM and do reduce

[root@ArkIT-Serv ~]# resize2fs /dev/VG0/lv1 100M
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/VG0/lv1 to 25600 (4k) blocks.
The filesystem on /dev/VG0/lv1 is now 25600 blocks long.
How to Shrink File System

File System Reduced from 1GB to 100MB

Reduce Disk Size

File System has been reduced from 1GB to 100MB but LVM size not yet reduced from 1GB to 100MB. To avoid file system corruption first we reduce file system after the reduce actual LVM.

[root@ArkIT-Serv ~]# lvreduce -L 100M /dev/VG0/lv1
 WARNING: Reducing active logical volume to 100.00 MiB
 THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv1? [y/n]: y
 Size of logical volume VG0/lv1 changed from 1020.00 MiB (255 extents) to 100.00 MiB (25 extents).
 Logical volume lv1 successfully resized
Reduce LVM Partition Size Linux

Reduced LVM Partition Size

Un-Comment mount entry in fstab file and run mount -a command to re-mount file system

[root@ArkIT-Serv ~]# cat /etc/fstab |grep lv1
/dev/VG0/lv1 /lvm1 ext4 defaults 0 0

[root@ArkIT-Serv ~]# mount -a
[root@ArkIT-Serv ~]# df -Th /lvm1
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VG0-lv1 ext4 82M 532K 75M 1% /lvm1

Conclusion

Shrinking File System always an risky process if you miss single step when your trying to reduce lvm partition size it simple corrupt your entire file system. You will loose all the data from that LVM. Make sure you have complete backup of LVM before shrinking it.

Related Articles

Linux Learners Guide from Basic to Advanced

What is Shell & Shell Scripting Very Basic

How to Reset Ubuntu Root Password Steps

How To Troubleshoot When FS is Full

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *