I was thinking of implementing the rsync / hardlink / snapshot backup strategy and was wondering how much dataspace a hardlink hard link takes up. Like Like, it has to put an entry for the extra link as a directory entry, etc. I couldn't I couldn't find any information on this and, and I guess it is file system dependent. The only The only info I could could find was suggestionsanecdotal: Either Either they take no space (probably meaning they take no space for file contents). Or the space, or the space they take is negligible, so they only take only a few few bytes to store the hardlinkhard link.
I took a couple of systems (one a vm VM and one on real hardware) and did and did the following in the root directory, as root:
The usr directory had about 54,000 files files. The The space used on the hdHD increased by about 34 MB MB. So So this works out around 600 bytes bytes per hardlink, orhard link – or am I doing something wrong?
The file name size is about 1.5 MB MB altogether (I got that by doing ls -R and redirecting it to a file).
The rsync with hardlinkshard links works so well I was I was planning on using it for daily backup on on a couple of the work servers. I also I also thought it would be easy to make incremental backups / snapshots like this for a considerable period of time. However, after ten days 30 MB MB is 300 MB MB and so on. In addition, if there have only been only a few few changes to the actual file data/contents, – say, a few hundred KB KB – then storing 30+ MB MB of hardlinkshard links per day seemed excessive, but I take your point about the size of modern disks. It It was simply that I had not seen this hardlinkhard link size mentioned anywhere that that I thought thought I may may be doing something wrong. Is 600 bytes Is 600 bytes normal for a hardlinkhard link on a Linux OS?
To calculate the space used, I did a df before and after the cp -al.
I re-ran the tests again to test the answerGilles's answer (given below that) that a directory directory/folder entry takes up 4 KB KB and this this was skewing my numbers, so so this time by placing 20,000 files files in a single directory and and doing the cp -al to another directory. The results The results were very different, after. After taking off the length of the filenames, the hardlinks the hard links worked out to about 13 bytes bytes per hardlinkhard link, much much better than 600. For For completeness, I did the test again, while while working on the answer given below saying that this is due to each entry for a directory directory/folder taking up 4 KB. But But this time I created thousands of directories and placed one file in each directory. The result after the maths (increased space taken on hd /HD divided by number of files, ignoring directories) was almost exactly 4 KB KB for each file, showing that a hardlink hard link does only take up a few bytes but that an entry for, but an actual directory/folder takes 4 KB KB.