How to reclaim additional disk from XFS filesystem?

Latest response

Hi,

I've got 2 physical disk(/dev/sdd1 & /dev/sdm1) attached to 1 volume group (bck101). 1 logical volume with xfs filesystem type has been created from bck101 volume group.

[root@oktst5123 ~]# pvs | grep bck
/dev/sdd1 bck101 lvm2 a-- <200.00g 0
/dev/sdm1 bck101 lvm2 a-- <200.00g 0

[root@oktst5123 ~]# df -h /seamnt/bck101
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/bck101-bck101 400G 62G 339G 16% /seamnt/bck101

Is there anyway to reclaimed/ remove 1 physical disk (/dev/sdm1) since usage is only 62GB

Responses

Hi Zahari,

This tutorial explains everything in an understandable way, and shows what you have to do ... :)

CentOS / RHEL : How to remove used Physical Volume(PV) from Volume Group (VG) in LVM

Regards,
Christian

Hi Christian,

Thanks but that tutorial is only apply for ext4 filesystem type. I know that for xfs filesystem cannot be reduce/shrink using lvreduce. but sync the logical volume (bck101) has been extended by adding another 200GB physical disk (request for temporary extend), I need to know if there is any way to reduce back the logical volume so that I can claimed back the 200GB disk.

Hi Zahiri,

XFS shouldn't matter, because you don't reduce the volume, but rather move the content of the disk you want to remove to the disk you want to keep - and afterwards remove the empty disk. :)

Regards,
Christian

As you can't shrink an XFS file system and it looks like it is taking up the full 400GB you have available, I think the only solution to end up with a smaller XFS file system is to copy the data off somewhere, replace XFS with a smaller file system, then copy the data back. I don't think the use of LVM changes that statement, though it may be possible to do without extra physical disk space if you are using LVM thin pools for your existing volume.

On second thoughts there might be in indirect way to shrink it, as the fstransform package (eg. from EPEL) may be able to transform your XFS file system to ext4 which you could then shrink, use the LVM instructions above to reclaim your disk, and then transform your file system back to XFS. I have previously done XFS to ext4 on Fedora (albeit on something I didn't mind breaking), and it looks like you might be to do resizing with it as well (so going via ext4 may not be needed). Of course it would be a good idea to back up your data first before trying any of this.

Zahari,

Only a backup, umount, vgreduce, lvcreate, mkfs.xfs, mount, restore will be the wat to go.

As mentioned by otters, xfs

May I know what is the best way to backup xfs filesystem? since I need to backup 62GB of data to other lvm? My college is suggesting using rsync. some folk are suggestion using xfs utility such as xfsdump/xfsrestore. Any thoughts, guys?rsync, xfsdump, lvm snapshot,clone?

Depends on how important filesytem metatdata is to you. Generally, your "highest fidelity" copies will be with block-for-block copy tools like xfsdump.