Appendix 3 Introduction to File Hard Links
Bonus 3: A Brief Introduction to File Hard Links
Have you ever wondered about a question that often goes unnoticed:
Why does my file icon appear in a specific location on my computer? Why, when I double-click a Word file on my desktop, can the computer read and open it? Where exactly is this file?
This file is, of course, stored on our computer’s hard drive.
Think of the hard drive as a blank sheet of paper. The .docx file is a long string of 01011101010… data written on that paper. We call this collection of data a data block.
Therefore, at its core, when we double-click a .docx file, we are essentially instructing the computer to read this specific chunk of data from the hard drive.
Now, have you ever considered why, when we double-click a file’s icon, the computer knows exactly which data block on the hard drive to read?
This is because the icon points to that specific area on the hard drive.
The word “points” is crucial here.
It acts like an arrow, directly pointing to the data block that belongs to it on the hard drive. The computer follows this arrow to find the data block and then reads its contents.
For now, let’s call the file’s representation on the computer an “icon.”
Let’s think further:
Is the relationship between an icon and a data block necessarily one-to-one?
In fact, it doesn’t have to be.
A single data block can have multiple icons pointing to it.
However, one icon cannot point to multiple data blocks. This would cause chaos in the operating system.
(This aligns with the definition of a function: one y can correspond to multiple x values, but one x cannot correspond to multiple y values.)
Here, we give our so-called “icon” a new name.
That name is:
Hard Link
A data block can have multiple icons. Each of these icons is a hard link to that data block.
All hard links to the same data block are equal in status because they all point to the same data block.
Now, let’s think about this: What does it mean to delete a file? What does it mean to erase a file?
Some people say moving a file to the Recycle Bin is deletion. Others say emptying the Recycle Bin is deletion.
In reality, emptying the Recycle Bin is the actual deletion operation. Moving a file to the Recycle Bin is merely a file move operation.
The Recycle Bin
The Recycle Bin is just a folder. When we move a file to the Recycle Bin, we are essentially moving it into this folder. On each disk partition, there is a folder named “Recycle.bin” that contains the files in the Recycle Bin.
You can check this in the root directories of your C: or D: drives, but you need to enable “Show protected operating system files” in File Explorer’s options.
Of course, files from the C: drive go into the Recycle.bin on C:, and files from the D: drive go into the Recycle.bin on D:.
So, moving a file to the Recycle Bin is not a true deletion; it’s a file move operation.
When we empty the Recycle Bin, the file is truly deleted.
Please note, I use the word “deleted” rather than “erased.”
Erasing
What is erasing? Erasing actually happens after deletion. When we empty the Recycle Bin, the file’s data block does not immediately disappear from our disk.
The operating system simply places a “tag” on the data block corresponding to the deleted file.
A tagged data block can then be freely overwritten with new data—new 1010001010…
This action is called overwriting.
When a data block is completely overwritten with new data, we say the data has been fully erased. At this point, the data block cannot be recovered.
Understanding this makes it easy to see how data recovery software on the market works. They simply find data blocks that haven’t been overwritten (or only partially overwritten) and restore their hard links. Thus, a file is recovered.
Therefore, a fully erased file cannot be recovered.
So, what is the practical use of hard links? How do we create multiple hard links for a file?
Uses of Hard Links:
1. File Backup.
Imagine this scenario: You’ve written a 1-million-word web novel that you treasure. One day, you accidentally delete it.
You think, “Oh no, my novel is gone. I don’t want to live anymore…”
But what if your novel had 3 hard links? You accidentally delete one—no big deal, you still have two left! Then you accidentally delete another—phew, you still have one. Then, one day, you accidentally delete the last one. And then, “I don’t want to live anymore…”
Just kidding. But this example illustrates that hard links are an excellent method for file backup.
We know that copy-pasting a file is also a backup method. So, what are the advantages of hard links over that?
(1) No matter how many hard links you create for a data block, it only occupies one unit of disk space.
I create 100 hard links for a 100GB file. When I check the folder size containing this file, I might be shocked: 10,000GB…
But when I check the remaining space on the partition in File Explorer, I see no change—it still only takes up 100GB.
(2) File updates are perfectly synchronized. If you use copy-paste for backup, you might not always keep the backup updated in sync. However, since hard links point to the same data block, when you click one hard link and modify the data block, all other hard links reflect the change simultaneously.
So, having multiple hard links for a data block is like giving that data block multiple hiding places on your computer. Only when all hard links to a data block are deleted can the operating system truly tag that data block and allow it to be overwritten.
This leads to one issue with hard links: the problem of cleaning them up.
Sometimes, we might forget how many hard links we created. We delete one, thinking we’ve removed them all, but there’s actually another hard link still lurking on the computer. This prevents the disk space from being truly freed.
However, with the right tools, we can significantly reduce this risk.
If we don’t use any third-party tools, we can only create hard links via cmd commands. Moreover, the icons for these hard links look identical to regular file icons, making them hard to identify.
The best tool I recommend for creating hard links is: Link Shell Extension.
Direct download link:
1 | |
Official website:
1 | |
The software is extremely small, installs quickly, and prompts you to restart File Explorer after installation. Then, a new option will appear in your right-click menu: “Select Source Link Point.”
Select a file as the source link point, then go to another location, right-click again, and choose “Create as… -> Hard Link” to create a hard link.
There’s a special bonus: It adds a small red arrow to the bottom-left corner of file icons that have two or more hard links. This makes it easy to identify hard links.
