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 wanted to create hardlinks to files on Windows Server 2003 and I stumbled upon the superuser question hardlinks on ntfs with windows. I tried mklink as one of the answers suggested and found that mklink isn't a standalone program but rather part of the cmd.exe command shell but was not implemented until later versions of the operating system.

I then tried the fsutil hardlink command and created the hard link as follows:

fsutil hardlink create c:\testfile.txt c:\temp\testfile.txt

which created the hardlink c:\testfile.txt pointing to c:\temp\testfile.txt.

When I edit c:\testfile.txt I notice that the file size and last modified time of c:\temp\testfile.txt would not immediately match; it would take a few minutes until it matched. Why would this be?

Also I noticed that when I do a "dir" or look at the link in Explorer that there is no indication it is a hard link. How do you subsequently know?

Secondarily: Before trying fsutil I tried linkd.exe which is part of the Windows Server 2003 resource kit. It appeared to create the link just fine but I would receive "Access Denied" whenever trying to edit the link. Any ideas why?

share|improve this question

1 Answer 1

I can only answer the second of your questions at the moment.

A hard link looks to the OS as though it were the original file. That is intentional, if you delete a hard link for example, it deletes the original file as well. That is by design. So there is no easy way of detecting that it is a link at least visually in Windows Explorer.

UPDATE: Many thanks to @Vedran for correcting me & giving a much better explanation of hardlinks on NTFS. Also for reminding me that I shouldn't assume that what used to be true may not still be true.

"they are all the original. Different filenames pointing to the same bits of data. When there is noone pointing at that data anymore, only then it can be considered as free space."

Under newer versions of Windows at least, hard links are clearly indicated in Windows Explorer as links.

As an aside, the excellent LinkShell Extension is very helpful for creating different type of link and junction from Windows Explorer.

share|improve this answer
    
You make an interesting point. It just occurred to me that while of course the file system knows that a hardlink exists (fsutil hardlink list will show them), Explorer probably needs a shell extension which would indicate this. I'm still surprised that the existence of the hard link isn't shown by default since even though the link looks like it's the original file, there's still a "connection" between that file and the destination one. –  Howiecamp Mar 4 '13 at 22:24
    
Hard links are dangerous! Use softlinks if possible as they are more obvious. Of course, they don't work everywhere. For an extension to help with links, try LinkShellExtension. I use it all the time. –  Julian Knight Mar 4 '13 at 22:33
    
@Howiecamp every hardlink is the original file, all of them just happen to point to the same blocks of data. –  Vedran Jan 15 at 14:16
    
Only if you delete all hardlinks the data will be deleted. –  Vedran Jan 15 at 14:17
    
@Vedran: Really? I rarely use them myself but I seem to remember that last time I tried, deleting one deletes them all. How can you tell which is the original without digging through the technical details of the filing system? I must do some testing - or maybe life is just too short! –  Julian Knight Jan 17 at 15: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.