XFS filedisk manipulation

resize the capacity of an xfs partition

Albert Lacambra BasilAlbert Lacambra Basil

Reduce XFS fylesystem

XFS fylesystem can not be reduced, only extended. In order to reduce it, you need to delete the filesystem and then recreate it with the new capacity.

Before to delete it, we will backup it, and once the filesystem has been recreated, we will restore it.

Create backup
xfsdump -l 0 -f /ome-image /dev/mapper/centos-home
Delete partition
umount /home
lvremove /dev/centos/home
Recreate partition with desired capacity
lvcreate -L 20G -n home centos
Create filesystem
mkfs.xfs /dev/centos/home
Restore backup
mount /home
xfsrestore -f /home-image /home

Extend partition

Extend desired partition
lvextend -L +20G /dev/centos/root
Increase filesystem capcity to maximal partition capacity
xfs_growfs /