이미 복사된 파일을 조각으로 공유하는 방법(reflink)은 무엇입니까?

이미 복사된 파일을 조각으로 공유하는 방법(reflink)은 무엇입니까?

나는 다음과 같이 매일 다른 XFS 볼륨에 파일을 복사합니다.

# on monday
cp --sparse=always /mnt/disk1/huge.file /mnt/disk2/monday/huge.file
# on tuesday
cp --sparse=always /mnt/disk1/huge.file /mnt/disk2/tuesday/huge.file

이제 disk2에 있는 두 파일의 전체 크기를 차지합니다.

내가 주로 사용하는 동일한 파티션에서는 --reflink=auto복사된 파일이 조각을 공유하고 변경된 블록만 차지합니다. 그러나 대상이 다른 볼륨에 있는 경우에는 작동하지 않으므로 기존 복사본 두 개를 다시 연결하는 솔루션이 필요합니다.

불행하게도 이렇게 변경된 블록만 복사 cp하지는 않습니다 rsync(참조 연결 지원 없음). 그렇지 않으면 다음과 같이 합니다.

# on monday
cp --sparse=always /mnt/disk1/huge.file /mnt/disk2/huge.file
cp --reflink=always /mnt/disk2/huge.file /mnt/disk2/monday/huge.file
# on tuesday
cp --sparse=always /mnt/disk1/huge.file /mnt/disk2/huge.file
cp --reflink=always /mnt/disk2/huge.file /mnt/disk2/tuesday/huge.file

답변1

xfs에 대해서는 모르지만 btrfs에는 이 작업을 수행하는 중복 제거 명령이 있습니다. 바라보다https://btrfs.wiki.kernel.org/index.php/Deduplication

복제본과 독립적으로 중복 제거 단계를 실행할 수 있습니다.

요청한 작업을 직접 수행하려면 프로세스를 되돌릴 수 있습니다.

그것은 다음과 같습니다:

  1. 어제의 사본에서 참조 링크를 생성하여 기준선 생성

    cp --reflink=always/mnt/disk2/monday/huge.file /mnt/disk2/tuesday/huge.file

  2. 다른 위치에서 소스 파일을 읽고 업데이트 내용을 직접 작성합니다. 예:

    rsync --inplace --no-whole-file /mnt/disk1/huge.file /mnt/disk2/tuesday/huge.file

월요일과 화요일 백업 사이에 필요에 따라 변경되지 않은 블록만 공유되기를 바랍니다.

경고: 나는 이것을 시도하지 않았으며 그것이 실제로 당신이 원하는 것을 할 것인지 모르겠습니다.

바라보다https://superuser.com/questions/576035/does-rsync-inplace-write-to-the-entire-file-or-just-to-the-parts-that-need-to

이는 관련이 없을 수 있지만 rsync에 직접 reflink 지원을 추가하는 것에 대한 논의가 있습니다. 바라보다:

문제가 무엇인지 잘 모르겠습니다.

관련 정보