Re: mv: move files across bind mounts using the rename syscall
From:
Pádraig Brady
Subject:
Re: mv: move files across bind mounts using the rename syscall
Date:
Wed, 11 Dec 2024 14:29:47 +0000
User-agent:
Mozilla Thunderbird Beta
On 06/12/2024 12:07, Milan Hauth wrote:
currently mv fails to detect an identical filesystem
of source and destination file across bind mounts
instead of using the rename syscall
mv copies the file (to the same filesystem)
and then deletes the source file
obviously, this is not ideal:
- slow
- waste of disk space
- change of inode number
- unnecessary disk write operations (destructive)
currently mv fails to detect an identical filesystem
of source and destination file across bind mounts
Thanks for taking the time to explore a solution.
It does seem a bit messy though, and I'd be worried about edge cases,
so I'm not sure it's appropriate for mv to do this.
Perhaps another approach might be for you to use BTRFS subvolumes,
which are similar to bind mounts. When the rename() fails there,
mv will then try to reflink,unlink which should succeed (cheaply).
thanks,
Pádraig.