How to shrink /home and add more space on CentOS7
As others have pointed out, XFS filesystem cannot be shrunk.
So your best bet is to backup /home, remove and recreate its volume in a smaller size and give the rest to your /root volume just as Koen van der Rijt outlined in his post.
• backup the contents of /home
> tar -czvf /root/home.tgz -C /home .
• test the backup
> tar -tvf /root/home.tgz
• unmount home
> umount /dev/mapper/centos-home
• remove the home logical volume
> lvremove /dev/mapper/centos-home
• recreate a new 400GB logical volume for /home, format and mount it
> lvcreate -L 400GB -n home centos > mkfs.xfs /dev/centos/home > mount /dev/mapper/centos-home
• extend your /root volume with ALL of the remaining space and resize (-r) the file system while doing so
> lvextend -r -l +100%FREE /dev/mapper/centos-root
• restore your backup
> tar -xzvf /root/home.tgz -C /home
• check /etc/fstab for any mapping of /home volume. IF it is using UUID you should update the UUID portion. (Since we created a new volume, UUID has changed)
Hope this helps.
Kindly add this to sync the changes:
dracut --regenerate-all --force
An addition to Ari's answer as I was unable to ssh using public key authentication after following his instructions.
With selinux enabled you may get this message in /var/log/messages (with debug enabled in sshd_config) because /home was recreated:
SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys
Fix it by:
restorecon -R -v /home
You can't shrink an XFS filesystem.
You can only grow them with
It is currently not possible to reduce the size of a partition or logical volume with the xfs filesystem. As a possible workaround in some environments, thin provisioned LVM volumes can be considered as an additional layer below the XFS filesystem.
Find out what's taking so much space under
/ and split it out as its own filesystem.