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.

This is what I have:

--dir1
----file1
----file2

Then I created another directory dir2 with hard-links.

--dir2
----file1 (hard link to dir1/file1)
----file2 (hard link to dir1/file2)

Now I removed file1 and recreated a new one with the same name. How do I make the file1 in dir2 change the hard link to the new file?

share|improve this question
    
What does this have to do with rsync? –  kbyrd Nov 15 '11 at 23:04
    
Maybe not directly. dir2 is created using rsync. It's basically used as a building directory for the source code in dir1 so that some temporary building stuff can be written in this directory without mess up the source directory dir1. Also, dir1 is huge, so hard links can save up some space. –  leonbnu Nov 16 '11 at 0:36

1 Answer 1

up vote 1 down vote accepted

You need to rm dir2/file1 then redo the hardlink. Hardlinks are not like symlinks. Where symlinks are a pointer to an original file, hardlinks are generally indistinguishable from the original file. When you deleted dir1/file1, dir2/file1 became the new "original". So, in order to have a hardlink named dir2/file1, you have to get this now-original-file dir2/file1 out of the way.

share|improve this answer

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.