12

Is there a way to use the copy-on-write cloning feature of APFS to reclaim space from existing duplicate files?

When you copy a file on APFS, it doesn't actual duplicate the file blocks, instead it just clones the metadata. That prevents it from using any more space until you actually make an edit to the duplicate file. It seems like there should be some tool to find existing duplicates and replace them with clones, reclaiming the space used to store the duplicate.

Related questions on Apple Communities and the MacRumors Forums don't have anything.

  • 2
    Hard to believe that nobody wrote an app to do this yet. On my home folder alone, there's 4.41 GB to be saved from doing this. That's far from a negligible amount. Take note: app developers, I'd gladly pay a few dollars for this! – swineone Feb 14 at 12:28
3

There are some alpha-quality open source scripts that try to do this - https://github.com/ranvel/clonefile-dedup

  • Yeah, I found this one too. Unfortunately there are a couple of reasons I don't find it usable: ultimately, it is just using cp -c, which discards all the metadata of the origin file (owner, permission, extended attributes, etc.). And there's no reason it couldn't just be done with a shell script, calling sqlite3 directly—instead, you have to install Python 3, which means its off-limits to non-admins who can't change settings to run unsigned/non-App-Store signed code. – Geoff Nixon Dec 19 '18 at 7:30
  • I submitted some changes (and they were approved) to github.com/ranvel/clonefile-dedup Now it will preserve file date and time, as well as chown/chmod attributes. – George Yohng Aug 3 at 8:38
0

See also https://github.com/deckarep/apfs-compactor, which is also just a prototype.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .