Windows 7: hard link, symbolic link and junction

43,816

Solution 1

The easiest way for most people to understand a symbolic (or soft) link is to think of it as a Windows shortcut.

If you make a symbolic link to a file, when you open it, Windows goes and looks up the original file in the filesystem index and then opens it. You can think of the symbolic link as being a signpost to the original file.

A hard link is an extra entry in the filesystem index that points to the same location on the disk as the original file's name. Think of the original name and the hard link as two doors into the same room.

A junction is a symbolic link to a folder (I think this is a hangover from previous versions of Windows and is now obsolete - I presume, but I haven't checked, that you can just use hard links now).

Solution 2

Directory Junction is "symlink to directory", so you can create "access points" to folders, available since NTFS 5.0 (Windows 2000). Directory Junction is NOT "a hard link to a folder", because junctions can point to non-existent directories. Directory and its junctions can be located on different NTFS partitions, but not across LAN. Non-elevated admins & user can create junctions.

NTFS Symbolic link was added to NTFS in Windows Vista. Symbolic link can point to a file or a directory (compare with junctions). Using them you can create "access points" to files & folders on different NTFS partitions AND across LAN. "The default security settings in Windows Vista disallow non-elevated administrators and all non-administrators from creating symbolic links."

"Symbolic link to directory" vs "Directory Junction" - by my experience, some (many?) apps does not work correctly with symbolic links, but they are fine with junctions, e.g. Total Commander and Windows file sharing (for LAN). If you share a directory with symlink - LAN users cannot traverse it, but they can do it for junctions. So after high-quality thing in Win2k, MS implemented some stuff in Vista...

Hard links can point to files only in the same partition, there is absolutely no difference between first file instance and other hard links to the same file. If you delete some hard link (first instance or another), file will continue to exist unless last hard link is deleted.

Junctions & symbolic links can be "broken" - it you rename/move the target, then they will point to non existent target. So you need to update they in such cases. But hardlinked files can be renamed/moved and all hardlinks will still be the same file, just with different names.

Share:
43,816

Related videos on Youtube

Pablo
Author by

Pablo

Updated on September 17, 2022

Comments

  • Pablo
    Pablo almost 2 years

    Possible Duplicate:
    What is the difference between NTFS hard links and directory junctions?

    What's the difference between them? in examples..

  • Joey
    Joey about 14 years
    Should get a −1 for » hard link to a folder «, though.
  • Joey
    Joey about 14 years
    ±1 here, +1 for correctly pointing out that a directory junction isn't a hard link, −1 for the third paragraph which goes way downhill. (For the record: Far can traverse directory symlinks just fine; maybe you're just using a broken OFM :-).)
  • Joey
    Joey about 14 years
    Note to add: Hard links can point to files on the same volume which isn't the same as a partition (a partition is a section of an individual drive, a volume can span many of those and even multiple drives; a volume is what the file system is on, not a partition).
  • Neal
    Neal about 14 years
    Oops, yes they are symbolic not hard links, I've amended accordingly. I see that the new mklink command still supports creating junctions as well as hard and soft links, but can see no reason for using a junction rather than a link.
  • JJ_Australia
    JJ_Australia almost 14 years
    Actually, the documentation does say that hard links can be applied to a folder, it's just a matter of time until someone figures out how to do it.
  • orad
    orad over 11 years
    Junctions are not obsolete and hard links cannot replace junctions as a hard link can only point to a target on the same partition (drive) but a junction in one partition can point to a target in another partition. I found the descriptions in this post very useful.
  • Niko Bellic
    Niko Bellic almost 8 years
    When would you choose to use a hard link over a symbolic link and vice versa?