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.

The title says it all... what's the difference? When do I use one and when do I use the other?

Added: Note that Junction points, Hard links and Symbolic (soft) links are three separate things on NTFS.

share|improve this question
2  
According to Microsoft documentation, there are three distinct categories: Hard link: msdn.microsoft.com/en-us/library/aa365006%28VS.85%29.aspx; Junction (soft-link): msdn.microsoft.com/en-us/library/aa365006%28VS.85%29.aspx; Symbolic link: msdn.microsoft.com/en-us/library/aa363878%28VS.85%29.aspx. –  Josip Medved Nov 9 '09 at 12:31
add comment

2 Answers

up vote 8 down vote accepted

NTFS data files are stored with all their attributes as an "inode" with an ID, and filenames point to the inode. All files have one+ hardlink. some tools can create extra names (hardlinks) which point to the same inode, which has a counter of the number of names pointing to it. If the number goes to zero, the OS deletes the file, the inode.

Special tools, like LN can create additional filenames which point to existing inodes, using a filename that points to them. Note that all the file attributes, including dates and times are stored with the inode, not the filename.

(Extra) hardlinks are useful when you want different names to point to the same data, read or write. They save space and overhead. However, they clobber programs which assume different names point to different data. e.g, if you replace references to duplicate files by hardlinks to a single file, then you have removed any backup you have! The windows OS is one program which assumes different names point to different sets of bits.

Hardlinks have to be on the same physical and logical volume.

They are useful for:

  • reducing path lengths since Windows just supports 256 characters or so.

  • reducing storage space of duplicate data files - eg, you could have multiple backups of a partition with multiple complete directory trees, but with hardlinks for files which have not changed since the previous backup.

Junction points are messier and use Reparse Points (which I do not understand). They can point to different physical or logical volumes but they have to be on the same computer. They apparently can be used like symlinks for directories, allowing a second name for the same destination, but limited to a single computer, rather than just a single volume.

Useful for reducing path lengths, or simplifying working with several programs with hardcoded directory names.

Same caveats, too! Many programs assume different names = different files.

And then there are symbolic links (which can go across networks), shortcuts and PIFs and .....

Also some information from Microsoft itself:

Basically, they're saying to use hard links only for files within the same volume (disk drive letter) and junction points only for directories on the same computer (they can span across different local volumes).

share|improve this answer
    
Does symbolic link work on hard disk (NTFS) level or it's on Windows operating system level concept? –  iSid Oct 8 '10 at 5:11
add comment

Hard link is just another name for a file. If you have file named A.txt and you have link L.txt, once you delete A.txt, you will still have access to it's data through L.txt. Only when both are deleted file is gone.

On other hand, you have a so called soft-link (junction if it is folder or symbolic link if it is file). In that case, when you delete A.txt, file is really gone. Deleting L.txt has no effect on file what-so-ever.

Hard links can only be used on same partition as originating file and soft-links can be used across partitions.

P.S. File and folder are mostly interchangeable as far as NTFS goes.

share|improve this answer
3  
Sorry, junctions and soft links are not the same thing for NTFS. :( –  Vilx- Nov 9 '09 at 12:15
1  
msdn.microsoft.com/en-us/library/aa365006%28VS.85%29.aspx Quote: "A junction (also called a soft link)" –  Josip Medved Nov 9 '09 at 12:25
3  
However, there is further distinction between junction (aka soft-link) and symbolic link, but I haven't went into details here. For those interested, details can be found in Windows documentation at msdn.microsoft.com/en-us/library/aa365006%28VS.85%29.aspx and msdn.microsoft.com/en-us/library/aa363878%28VS.85%29.aspx. –  Josip Medved Nov 9 '09 at 12:28
    
Since Windows Vista, there are both NTFS junctions (can only be pointed to directories) and Unix-style symlinks (can point to literally anything). –  grawity Nov 9 '09 at 13:01
add comment

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.