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.

On my computer I create a hard link

mklink /h git-link.exe git.exe
Hardlink created for git-link.exe <<===>> git.exe

Now they both take up space

2012-04-17  12:14 AM         6,905,039 git-link.exe
2012-04-17  12:14 AM         6,905,039 git.exe

What's the point of this? Why not just make a copy?

share|improve this question
1  
The number you see, "6,905,039" has nothing to do with how many bytes of space anything takes up. It's the size of the linked file if you were to read it, regardless of how many bytes it actually takes up on disk. So all that your output shows is that each of the two links point to a file that would read as that number of bytes. –  David Schwartz Apr 17 '12 at 6:47

2 Answers 2

up vote 10 down vote accepted

When you create a hardlink, you are creating two separate file system entries pointing to the same physical data on the disk.

When you do a dir, it displays the size of the data being stored at the location the file system entry is pointing at.

So if you create 100 hard links to a single file, they will all report the same size - they are reporting the size of the data stored. This does not mean that the hardlinks take up this space - in fact they do not. A hard link takes up very little space.

share|improve this answer
1  
Also, when you create a file in a directory, it's a hard link that puts the file in that directory. The mklink /h creates an additional link to the file that behaves precisely the same as the original link. (If you remove the original link by deleting the directory entry, the file will be just as if you had originally created it in the other directory.) –  David Schwartz Apr 17 '12 at 6:49

Fact is, there is no point in ever using directory hard links (junctions), is there ?

Considering the way they are handled by explorer, that is.

My point, using an example : one cannot hope to alleviate disk 'C' from its physical payload (moving appdata folders or program files to another disk 'E' and using hardlinks to repopulate 'C', thus keeping apps working). Windows explorer will still accumulate those links "sizes" to the -presumably- consumed space on 'C', throwing warnings at its user's face as soon as disk 'C' lacks free space, even if it relates to hardlinks "virtual" space consumption.

So, Windows 7's hard links ? Big disappointment.

share|improve this answer
1  
You confuse hard links with symbolic links. –  kreemoweet Nov 17 '12 at 18:41

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.