Hard Links on Mac OS X in Movies and Pictures

Mac OS X Background

Early versions of Mac OS X did not have hard links, but Apple added them in Leopard 10.5 to make use of in Time Machine.  Initially, the functionality was crippled, but as of Mavericks 10.9 (and perhaps earlier), full hard link functionality is available.

What is a hard link?

In the file system, a filename points to a particular inode, which contains the metadata about the file:

file1 ---> [Inode 317905] ---> [Address, Ref Count = 1]

When you a create a hard link, two separate file names point to the same inode:

file1 ---
        |---> [Inode 317905] ---> [Address, Ref count = 2]
file2 ---

file1 and file2 are completely symmetric. If you delete file1, file2 will still exist and still point to inode 317905. And if you delete file2, file1 will still exist and still point to inode 317905.

The file system maintains a reference count within each inode. If you delete both file1 and file2, the reference count for the inode drops to 0, and the space used by the file is marked for deletion.

Continue reading “Hard Links on Mac OS X in Movies and Pictures”