GrandPerspective icon

Hard links

Unix-based Operating Systems, including macOS, support the concept of hard links. Hard links can be used to place a file at multiple locations (i.e. within different folders) or under multiple different names on the same file system. Each of these hard links refers to the same data on the file system, only taking up space once. This for example implies that when you modify a hard-linked file, all hard-linked "copies" of that file are modified as well.

Hard links need to therefore be handled specially in order not to over-estimate the amount of disk space that they take up. GrandPerspective therefore handles hard links as follows. When a hard-linked file or folder is first encountered during scanning, it is included. Subsequently, if the same file or folder is encountered once more (in a different folder) it is ignored. So, inside a single view window, a hard-linked item appears at most once, thus correctly reflecting the size that is actually taken up on disk. However, where a hard-linked item appears in the view is fairly arbitrary. It can be in any of the folders where it appears. Which one depends on the order in which the folders are scanned.

When you delete a hard-linked file or folder, it is removed from the given folder. However, the amount of freed space will not increase, as the item will take up space on disk until all its hard links are removed.

See also