4

I have a VM with two XFS file systems on two separate virtual disks.

The first XFS is 2.5 TB big and the second one is 1.5 TB big.

The first XFS uses 844 GB storage reported by df -h, but in reality 7.3 TB:

]# df -h
/dev/sdb1                   2.5T  844G  1.7T  34% /a

]# du -sh /a
7.3T    /a

The second XFS is empty and ready:

]# df -h
/dev/sdc1                   1.5T  1.5T   20K 100% /b

The reason why I have to copy the data from /a to /b is because I have to shrink the disk. Since XFS does not support shrinking, I guess I have to do this method. (is there a better one?)

So I tried copying the data pretty dumb first by just using cp /a/. /b/ - but then the data grows and the real 7.3 TB appear. Which does not work, since /b is only 1.5 TB big.

After that I tried researching how to do this and I found this command:

xfsdump -l0 -J - /a | xfsrestore -J - /b

However, that command also does not work. Errors with No space left on device.

Does anyone have an idea how I could achieve this?

2
  • 1
    xfsdump doesn't support reflink, neither does rsync and cp only does it for new copies, not for transferring existing reflink structures over. There is duperemove which generates reflink for existing files but the catch is, the file has to exist in the filesystem first so the filesystem needs space to store. So it might be possible to find a solution step by step with that but it will involve some juggling and depend on your file structure. Commented Dec 29, 2023 at 7:51
  • Possible alternatives: you could make it a thin volume on LVM, so XFS keeps the same size but free space won't actually occupy physical disk space after fstrim; or you could switch to btrfs which supports shrinking. If your files are actually fully identical, not deduplicated by individual extents, you could use hardlinks (but any modification would affect all instances). If the files are no longer in active use, you could also consider restic and other deduplicating backup solutions. Commented Dec 29, 2023 at 11:24

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.