How to Reduce LVM Partition Size in RHEL and CentOS

In this guide, we will learn how to reduce or shrink LVM partition size in RHEL & CentOS systems.

Sometimes when we are running out of disk space in a linux system and if partition created on LVM , then we can make some free space in the volume group by reducing the LVM using lvreduce command.

In this guide, we will cover required steps to reduce the size of LVM safely on CentOS and RHEL systems.

Note: These steps are applicable only when you have LVM based partition and formatted either as ext4 or ext3.

Let’s assume, we want to reduce /home by 2GB which is on LVM partition & formatted as ext4.

[root@cloud ~]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/vg_cloud-LogVol00
                       12G   9.2G  1.9G  84%  /home

Step1) Umount the file system

Use the beneath umount command

[root@cloud ~]# umount /home/

Step 2) check the file system for Errors using e2fsck command

Run e2fsck command to check whether filesystem has any error or not. When we use ‘-f’ flag in e2fsck command then it will forcefully check or scan the file system even if the file system us clean.

[root@cloud ~]# e2fsck -f /dev/mapper/vg_cloud-LogVol00
 e2fsck 1.41.12 (17-May-2010)
 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/vg_cloud-LogVol00: 12/770640 files (0.0% non-contiguous), 2446686/3084288 blocks

Step 3) Reduce or Shrink the size of /home to desire size

As shown in the above scenario, size of /home is 12 GB , so by reducing it by 2GB , then the size will become 10GB. Run the following resize2fs command followed by the file system and size.

[root@cloud ~]# resize2fs /dev/mapper/vg_cloud-LogVol00 10G
 resize2fs 1.41.12 (17-May-2010)
 Resizing the filesystem on /dev/mapper/vg_cloud-LogVol00 to 2621440 (4k) blocks.
 The filesystem on /dev/mapper/vg_cloud-LogVol00 is now 2621440 blocks long.

Step 4) Reduce LVM size using lvreduce command

Execute the following lvreduce command,

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

Step 5) For the safer side, now check the reduced file system for errors (Optional)

Again run the e2fsck to check file system for errors after size reduction.

[root@cloud ~]# e2fsck -f /dev/mapper/vg_cloud-LogVol00
 e2fsck 1.41.12 (17-May-2010)
 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/vg_cloud-LogVol00: 12/648960 files (0.0% non-contiguous), 2438425/2621440 blocks

Step 6) Mount the file system and verify its size

[root@cloud ~]# mount /home/
 [root@cloud ~]# df -h /home/
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/mapper/vg_cloud-LogVol00
                       9.9G  9.2G  208M  98% /home

Perfect, above commands output confirms that /home size is reduced by 2GB, now the new size of file system is 10GB. That’s all from this guide, please do post your queries and feedback in below comments section.

Also Read : 8 Quick Date Command Examples in Linux

12 thoughts on “How to Reduce LVM Partition Size in RHEL and CentOS”

  1. During LVM reduction, It is always recommended to umount file system otherwise there can be corruption on the file system, though you try reducing the LVM partition online without umounting.

    Reply
  2. Hi, good post!

    One question, in step 4 it says “WARNING: Reducing active logical volume to 10.00 GiB
    THIS MAY DESTROY YOUR DATA (filesystem etc.)”. So it means that the data in /home are destroyed while de resize is performed?

    Reply
    • In the production environment, it is not recommended to reduce files system as it might lead to file system corruption and data destruction but there are some situation where we need to reduce it.

      So in Step:4 we will not loose any data as file system usage is 9.2 GB and we are reducing it from 12 GB to 10 GB and before reduction we are doing files system check with e2fsck command and resizing it with resize2fs command and in last we are reducing the file system.

      Reply
  3. I am trying to reduce root partition size. It’s showing below error:

    “on-line resizing required resize2fs: On-line shrinking not supported”

    Reply
  4. Thanks, but this is directions on how to reduce the size of a logical volume, not a partition (e.g. a physical volume).
    BTW. If you want to don’t want the volume unmounted you can create a snapshot, and use that while reducing the partition size. Only you need enough free space in your group so you can allocate the snapshot to have enough space to for the changing of the file system. But with USB sticks of 256G or greater being easily affordable, it is quite practical to put some physical volumes on a USB stick for your snapshot volume.

    Reply

Leave a Reply to tamer Cancel reply