Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file "a.txt" and its hardlink "ha.txt". If I open either of those files in notepad and save any changes it would appear in both files as they are still linked. But if I overwrite (copy) a.txt with another file with same name the hardlink breaks. What other operations do this?

Also, can I use it to backup a folder? Since if I ever change (overwrite) "a.txt" the hardlink automatically breaks and I have 2 copies. But because it depends on what I use to overwrite it (notepad certainly won't work) it ultimately depends on what operations in windows "breaks" the hardlinks and make copies?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Anything that deletes and recreates the target file will break the link. Some applications will do this, some won't. I don't think there's any way to predict this in advance.

Hard links are not a sensible backup mechanism, since there is only ever one copy of the file. Backups should always be to a different physical disk, anyway, in case the entire disk fails.

share|improve this answer
add comment

Anything that rewrites the filename will break the link. Modifying the file contents will not, nor will changing the filename metadata.

share|improve this answer
1  
Could you clarify "rewrites the filename"? Renaming a file does not affect the hardlink. –  grawity Mar 17 '12 at 23:28
    
One has to separate the concepts of "file name" and "file contents" in order to understand how hard links work. People have been conditioned by FAT/VFAT for so long into thinking that they are one and the same. The "file name" (which in reality is just a hard link) points to the "file contents" stored in inodes on disk. Removing and recreating the hard link in effect "rewrites" it. –  Ignacio Vazquez-Abrams Mar 18 '12 at 1:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.