How to Resize LVM Partitions: Reallocating Space from centos-home to centos-root in CentOS


4 views

Looking at your current setup, you have a 280GB disk with LVM configured, where most space is allocated to /home (223.6G) while the root partition (/) only has 50GB. Here's what we're working with:

# Current disk usage
$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   21G   30G  41% /
/dev/mapper/centos-home  224G   13G  212G   6% /home

# Physical volume layout
$ sudo lsblk -io NAME,TYPE,SIZE,MOUNTPOINT,FSTYPE,MODEL
sda2          part 279.5G            LVM2_member
  |-centos-swap lvm    5.9G [SWAP]
  |-centos-root lvm     50G /
  -centos-home lvm  223.6G /home

Here's how to safely shrink the home partition and extend the root partition:

1. Backup Critical Data

Before making any changes:

# Create a snapshot if using LVM thin provisioning
sudo lvcreate -L 10G -s -n home_snapshot /dev/mapper/centos-home

# Or make a traditional backup
sudo tar -czvf /tmp/home_backup.tar.gz /home

2. Unmount the Home Partition

sudo umount /home
# Verify it's unmounted
mount | grep home

3. Check Filesystem Integrity

# For xfs (your current filesystem)
sudo xfs_repair /dev/mapper/centos-home

# If you were using ext4 instead:
sudo e2fsck -f /dev/mapper/centos-home

4. Resize the Filesystem and Logical Volume

# Shrink the filesystem first (for xfs)
sudo xfs_growfs -D 150G /dev/mapper/centos-home  # Set target size

# Then shrink the LV (example: reducing to 100GB)
sudo lvreduce -L 100G /dev/mapper/centos-home

# For ext4 you would do:
sudo resize2fs /dev/mapper/centos-home 100G
sudo lvreduce -L 100G /dev/mapper/centos-home

5. Extend the Root Partition

# First check available space in volume group
sudo vgdisplay centos

# Then extend the root LV
sudo lvextend -L +123G /dev/mapper/centos-root

# Finally resize the filesystem
sudo xfs_growfs /dev/mapper/centos-root

If you're comfortable with LVM, you can do this in one operation:

# Move 100GB from home to root
sudo lvresize --resizefs -L -100G /dev/mapper/centos-home
sudo lvresize --resizefs -L +100G /dev/mapper/centos-root

After completing these steps:

# Check new sizes
$ df -h
$ sudo lvs

• XFS can only be grown, not shrunk, while mounted
• Always have backups before resizing partitions
• Consider downtime requirements for production systems
• Monitor filesystem usage after resizing


When working with CentOS systems using LVM (Logical Volume Manager), you might encounter situations where disk space allocation needs adjustment. In this case, we have a VM with:

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   21G   30G  41% /
/dev/mapper/centos-home  224G   13G  212G   6% /home

The disk shows significant underutilization in /home while / might need more space for system operations.

Before proceeding, ensure you:

  • Have root privileges
  • Backup important data
  • Unmount the /home partition if possible
  • Check filesystem integrity

1. Verify Volume Group Free Space

# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  VG Size               279.50 GiB
  PE Size               4.00 MiB
  Total PE              71552
  Alloc PE / Size       71552 / 279.50 GiB
  Free  PE / Size       0 / 0   

2. Reduce the Home Partition

First, check filesystem size and reduce it:

# e2fsck -f /dev/mapper/centos-home
# resize2fs /dev/mapper/centos-home 100G

Then reduce the logical volume:

# lvreduce -L 100G /dev/mapper/centos-home

3. Extend the Root Partition

First check available space in volume group:

# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  centos   1   3   0 wz--n- 279.50g 123.60g

Then extend the root partition:

# lvextend -L +123G /dev/mapper/centos-root
# resize2fs /dev/mapper/centos-root

If you prefer not to unmount /home, you can use this method:

# lvresize --resizefs -L -50G /dev/mapper/centos-home
# lvresize --resizefs -L +50G /dev/mapper/centos-root

After completing the operations, verify the new layout:

# df -h
# vgdisplay
# lvdisplay

Remember to update your /etc/fstab if you changed any mount points during the process.

If you encounter "Cannot resize filesystem" errors:

  • Ensure the filesystem isn't mounted
  • Check for bad blocks with fsck
  • Consider using xfs_growfs for XFS filesystems instead of resize2fs

For LVM-specific errors:

# dmsetup remove_all
# vgchange -a y