Windows hard link taking up space?

2

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?

Steven Penny

Posted 2012-04-17T05:37:39.023

Reputation: 7 294

1The 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 – 2012-04-17T06:47:16.410

Answers

12

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.

Paul

Posted 2012-04-17T05:37:39.023

Reputation: 52 173

1Also, 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 – 2012-04-17T06:49:52.367

-3

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.

JL ARNAL

Posted 2012-04-17T05:37:39.023

Reputation: 1

3You confuse hard links with symbolic links. – kreemoweet – 2012-11-17T18:41:23.107