[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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
this is possible using /proc/self/mountinfo
proof of concept:
https://github.com/milahu/move-files-across-bind-mounts
related:
https://serverfault.com/questions/327447
https://unix.stackexchange.com/questions/406351
https://unix.stackexchange.com/questions/380025
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.