Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Lets suppose that there are:

  • a folder and
  • a junction point or a symlink to that folder

When the original folder is moved to a new location, both the junction point and the symlink fail (point to an orphaned location). The failure of the link is not the case when a hard link to a file is created. Any hard link to a file can be moved to other folders and it will still point to the same physical file on the hard drive.

Is there a way to create a 'link' to a folder, so that when the folder is moved, the link 'tracks' the location of that folder and still works after the move operation?

If not, why is this not possible.

share|improve this question

1 Answer 1

You can use junction.exe from the SysInternals suite to create hard links to directories in XP.

Creating hardlinks to files can be done natively, with the fsutils (command line) utility.

However, what you're asking for doesn't exist in NTFS. I found a decent rundown of the NTFS implementations of Hard Links, Junction Points, and Soft Links, but as far as what you're asking about, junction points are the directory/folder version of file hard links under NTFS. And, unlike hard links, they will not update if their target is moved or removed. As to why this is the case, because that's the way Microsoft chose to implement junction points in their file system.

Per Michael Hampton's comment, I did a little Googling about directory hard links, and while I couldn't find anything immediately from Microsoft as it relates to true hard links creating loops in the directory structure, I did find something from Unix and Linux .SE with a good explanation of the problem, and the fundamentals are the same, so it might be worth a read.

share|improve this answer
    
Thanks for the response. According to what I've read, junction.exe can only create junction points to directories and fsutil can only create hard links to files. There is no way to create a hard link to a folder with those tools. –  colemik Feb 17 at 17:13
    
@trismarck A junction point (in NTFS) is a hardlink to a directory. To my knowledge, that's as good as it gets. My apologies for not reading your question thoroughly enough, but I'll update my answer. –  HopelessN00b Feb 17 at 17:20
    
@@HopelessN00b yes, the nomenclature on the subject of 'links' to files on the filesystem is 'hard to discern'. One could name a hard link a link that is 'transparent' for the underlying application (the filesystem transparently reparses the destination path once it hits a hard link) and one could name a hard link a link that is able to 'track' the location of the target folder the link points to, when the location of that target folder changes. I'm after the second case. That's why there is trackable and ~ in the topic of the question. Thanks for clearing that up. –  colemik Feb 17 at 17:31
2  
True hard links to directories aren't allowed because they would create infinite loops in the directory structure. –  Michael Hampton Feb 17 at 17:48
    
@MichaelHampton just to clear this out, it is already possible to create infinite loops in the directory structure by using just junction points. See Link Shell Extension: schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html . –  colemik Feb 17 at 19:50

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.