Hard links

Classic hard links

Each file on your disk connects a name to a certain area on disk, with a one-to-one relation. But, sometimes it’s necessary to reference the same area on disk with more than one name (or link). This can save you a lot of disk space, because otherwise you’d need to copy the file’s data.

Links are extensively used by the operating system, by Time Machine and by many Apple apps (like iTunes, Photos etc.) and also by some third-party apps.

Most modern file systems support two kinds of links: soft links and hard links.

A soft link is basically a small file that contains only a reference to the original file. DaisyDisk counts soft links simply as small files and they do not create any problems when calculating folder sizes.

Unlike soft links, for hard links, it’s impossible to tell which of them is the original file and which is a reference, because all hard links to the same area on disk are indistinguishable from each other. Some apps (including Finder) do not take this fact into account and count parallel hard links twice or more times as distinct files, which produces wrong folder sizes.

DaisyDisk detects hard links and counts them correctly, i.e. only once each. The first occurrence of a hard link (the primary link) is counted, and the rest of parallel hard links (secondary links) are assigned a virtual size of 0 bytes, so that they do not contribute to the overall folder size.

Note that the linked disk space is not released until there is at least one hard link pointing to it. It may sometimes create confusion, because it looks like no free space appears after you delete a file.

To help you recognize hard links, DaisyDisk displays visual hints in the sidebar list. For primary hard links, there is a white rectangle inside the item’s bullet. For secondary hard links, there is a dark circle inside the bullet.

Hard links

When you delete a hard link in DaisyDisk, the app will update all parallel hard links accordingly, and recalculate the overall folder size correctly. (If you delete a hard link outside DaisyDisk, you should rescan in DaisyDisk to update the visual hints and the folder size.)

Clones on APFS

Clones are a new feature of APFS. They allow to create instant copies of files and folders that do not occupy additional disk space. Clones superceded hard links for Time Machine’s local snapshots on macOS High Sierra.

Similar to hard links, clones also reuse the same disk areas for different files. However, while a hard link can only reference the entire file as a single block, clones can consist of multiple blocks, each being referenced by several files. In other words, clones provide a more fine-grained control of how disk space is reused. Thanks to this trait, clones can consume less disk space by saving only the changed blocks of a file, and merely referencing the rest of unchanged blocks from other clones.

Unfortunately, macOS currently does not provide a way for DaisyDisk to identify clones and calculate their size correctly with respect of the shared blocks. In result, you may occasionally notice that the aggregate size of a bunch of files can be smaller than the sum of the same files taken separately.

But fortunately, the use of clones appears to be very limited on a typical APFS disk — mostly in local snapshots, for which DaisyDisk has other tools.