What is the difference between NTFS Junction Points and Symbolic Links?
Asked Answered
W

6

196

At a high level, the only obvious difference between NTFS Junction Points and Symbolic Links is that Junctions are only able to be directories, while SymLinks are allowed to also target files.

What other differences between the two exist?

(Note, I've already seen this question and what I'm looking for is a bit different -- that question is looking for a pro and con list, I'm looking for a set of technical differences)

Wo answered 28/1, 2012 at 2:53 Comment(0)
A
158

Symbolic links have more functionality, while junctions almost seem to be a legacy feature because of their limitations, but the security implications of these limitations are specifically why a junction might be preferred over a symbolic link. Remote targeting makes symbolic links more functional, but also raises their security profile, while junctions are safer because they are constrained to local paths. So, if you want a local link and can live with an absolute path, you're probably better off with a junction; otherwise, consider a symbolic link for its added abilities.

enter image description here

*The statement of difference in speed/complexity comes from an unverified statement in the Wikipedia entry on NTFS reparse points (a good read).

**Ever since the Windows 10 Creators Update, one can enable Developer Mode to remove the admin restriction for NTFS symbolic links.


Other NTFS Link Comparisons

Here are some other comparisons on the topic, but these can be misleading when considering junctions because they don't list the benefits I list above.

Taken from here (a good introductory read)

enter image description here

From SS64 page on MKLink

enter image description here


Comments about Terminology

Junctions are Reparse Points (may be described as symbolic links)

NTFS Junctions and NTFS Symbolic links are really doing the same thing in the same way (reparse points), aside from the aforementioned differences in how they're processed. In fact, technically, a Junction is a "symbolic link" in the more general sense of the word, and sometimes documentation might call a Junction a symbolic link, as is the case here. In such cases, "symbolic link" does not mean NTFS Symbolic Link which is different than a junction (see below).

NTFS

Even though the OP specifies this, it's worth pointing out that "symbolic link" is a very general term that is not specific to NTFS. So, to be specific, this comparison is about NTFS Junctions vs. NTFS Symbolic Links.

Ailsun answered 2/2, 2018 at 16:28 Comment(11)
Junction Points and Symbolic Links are both Reparse Points, but Junction Points most definitely are not Symbolic Links! Oh and the table is wrong on one count also. The target of a Junction Point must exist upon creation, but it may indeed be removed later on.Messuage
@Messuage Yes, you're right if what you're saying is that an NTFS Junction is not an NTFS Symbolic Link. I can see how my wording might be misunderstood to say this. I'll edit to clarify, but the point is that, in this context, "symbolic link" refers to NTFS Symbolic Links which are specific implementations of the more general "symbolic link" idea to which Junctions also belong. Did you follow the link I posted? It's not saying that an NTFS Junction is an NTFS Symbolic Link, but the term "symbolic link" can be used to describe a junction.Ailsun
fair enough, when referring to the concept it may be one way to think about it. But I really think the term reparse point brings the concept home, because it explains much more what's going on in the NT object manager and that this concept goes way beyond what symbolic links used to be on Unix, for example (where they are ordinary files with a special flag). And yes, I've heard junction points explained as "symlinks for directories".Messuage
@Messuage Also, I don't see the issue you mention about the table being wrong. Are you referring to the "Can point to a non-existent target" characteristic? And are you saying that this is wrong at least when first creating a junction? If you're certain that that's the case in a specific environment (maybe for Windows XP or because of security settings) I'll make note of that but in my experience and from documentation (and I just confirmed on Windows 10) a junction can always target a non-existent path, even upon creation... there might be security settings that restrict this.Ailsun
Junctions aren't legacy. They implement mount points (bind/volume), not symlinks. When a path is parsed in an open, the system remembers traversed junctions in order to evaluate relative symlinks that traverse mount points. These traversals need to handle a junction as if it's a regular directory, whereas a symlink is parsed as its target path. For example, say "C:\junction" and "C:\symlink" both target "E:\spam", and the relative symlink "E:\spam\eggs.txt" targets "..\eggs.txt". Then "C:\junction\eggs.txt" resolves to "C:\eggs.txt", and "C:\symlink\eggs.txt" resolves to "E:\eggs.txt".Abed
@0xC0000022L, anyone that says junctions are "symlinks for directories" is categorically wrong. There's misleading information out there. This gets perpetuated by Unix devs, who do know the difference between mount points and symlinks in the Unix model but couldn't care less about accurately understanding Windows, and also by Windows devs who know just about nothing (correct) about Unix and can't be bothered to worry about the behavior differences since mixing mount points and absolute/relative symlinks in a complex tree is rare enough that they can get by with sloppy definitions.Abed
@0xC0000022L, Microsoft devs are themselves no exception here, and documentation/wiki writers are worse. As far as I can tell, the only person at Microsoft who understood this well was the developer who augmented the behavior of junctions for Vista. The level of care taken to implement this properly for mount points is obvious in undocumented function names in the I/O manager. Probably that developer has long since left Microsoft, and the only institutional knowledge that remains is in source comments that no one reads.Abed
@ErykSun haha, could well be that the respective dev has since left MS. The story doesn't exactly sound all too strange for most software companies ;) ... agreed about junctions not being symlinks, but when using metaphors to explain concepts using (wrong) comparisons can still be useful to (superficially) explain a concept. Not sure this is the place for superficial explanations, though.Messuage
There is a third party driver available for Windows XP that allows symbolic links to work.Barrator
does 'security profile' mean security risks ?Mornay
Best answer in the www, whish I could upvote it more!Noles
J
38

The places I find the most useful for the differences:

http://blogs.msdn.com/b/junfeng/archive/2006/04/15/576568.aspx

http://www.hanselman.com/blog/MoreOnVistaReparsePoints.aspx

Postulate: Symlink is to Junction in Windows as Symlink is to Hardlink in Unix.

http://en.wikipedia.org/wiki/Symbolic_link#Windows_7_.26_Vista_symbolic_link

Windows 7 and Windows Vista support symbolic links for both files and directories with the command line utility mklink. Unlike junction points, a symbolic link can also point to a file or remote Server Message Block (SMB) network path. Additionally, the NTFS symbolic link implementation provides full support for cross-filesystem links. However, the functionality enabling cross-host symbolic links requires that the remote system also support them, which effectively limits their support to Windows Vista and later Windows operating systems.

http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-symbolic-links/

A symbolic link, as created by Windows, is much similar to a directory junction, but unlike a directory junction it can point to a file or a remote network file or directory. The target may be defined as a path relative to the symbolic link position, or an absolute path in the current volume or another one. Also note that symbolic links to files are different from symbolic links to directories and the target must match the definition.

Jezabelle answered 28/1, 2012 at 3:6 Comment(4)
For Windows 7 specific information: msdn.microsoft.com/en-us/library/windows/desktop/…Stockman
The accepted answer is already three years old, but i would like to point out that NFTS junction points do not compare to hardlinks in Unix, as implied in the quoted postulate. This should be obvious, since a junction point cannot reference a file but a hardlink can. NTFS also supports hardlinks (which are different from junctions), and those are more or less are comparable to Unix hardlinks.Fuchsia
@elgonzo Totally agree. AFAIK a Unix hard link can only refer to a file, so it doesn't look like NTFS directory junction at all.Coil
The "postulate" makes no sense, since "normal" Unix filesystems do not allow hard links to directories. Only special filesystems do (for example, sysfs, normally mounted as /sys).Hortative
M
28

Functionally, in windows, once created, there is no real difference. However, there are significant differences between them in what they can do. Junctions can be used only for the creation of links to folders, either on the same drive or different drives, but only if those drives are on the local system (you can not create a junction link to a folder over a network.) Symbolic links however, do not have the same restrictions. Symbolic links can be used to link to either files or folders and those files or folders can be located either on the same system (same drive or different drives) or to a network share and can make use of relative location symbolics ("\\system2\foldera\file.txt", "d:\foldera\file.txt", "\\system2\foldera", "d:\foldera" or "d:\foldera\folderb.." with the resulting link for the last 2 examples being the same location.) Relative location symbolics can be ".", "..", current drive relative function (if current drive is c:, then specifying "\tempa\folderb" results in a link to c:\tempa\folderb,) and current directory relative (if the current directory is d:\foldera\folderb, then specifying "d:file.txt" results in a link to d:\foldera\folderb\file.txt.)

To sum it up: Junctions Points are limited to folders on the local system only, while Symbolic Links can create links to folders or files accessible via a UNC path or on the local system with more versatility in how those locations are designated. Symbolic Links is basically a more versatile replacement for both Junction Points and Hard Links. Plus, Symbolic Links are compatible with Unix and Linux when creating a cross platform UNC pathed link.

Hopefully, this answers your question in a satisfactory manner. Edited to correct typographical errors.

Miliaria answered 2/2, 2016 at 3:48 Comment(0)
F
16

Link Shell Extension, http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html, is a great tool for creating and viewing many kinds of links. It also has excellent documentation.

[On a full install, it adds a new properties tab if you're looking at an advanced link. At also adds icon-overlay arrows for the various link types - scroll to the FAQ section if these do not show up; Windows only supports thirteen overlays; he shows a registry workaround. An example of its informational usefulness: Unsuccessfully trying to get privileges to what you thought was a folder, but in fact was a system-provided Junction Link, often used for compatibility purposes with older editions of Windows.]

Junctions and Symbolic Links act essentially identically when created for a directory on a local system.

However:

They act differently over a network. This link describes this behavior: https://superuser.com/questions/343074/directory-junction-vs-directory-symbolic-link

If you think of Junction Links as "shortcuts that fool the OS as to location" you'll have a good practical simile of their use and what breaks them. The main difference is that if you copy Symbolic Links or Junctions, it copies the target, rather (like shortcuts) merely the file that contains the pointer. As with shortcuts, you can delete Symbolic or Junction Links without removing the target files/folders. [Hard Links, the file is only deleted with the removal of the last link - including from the recycle bin. Look at the properties tag in LSE for any of these links to see the target or the reference count for Hard Links.]

Hard Links or Shortcuts are the only link types that can be moved with no side-effects like breaking or copying the entire target. Moving the target always breaks the links, though they can easily be updated in the properties tab (shown with LSE) or re-created, if complicated, with LSE.

The creation of Symbolic Links requires administrator privileges whereas Junctions do not. This plus the extensive, internal OS use of Junctions suggests that Windows handles them in an intuitive, expected manner. [Do be somewhat wary of unexpected side-effects from system folders (from experience with Win 10).]

[Some of the backup-specific features of Link Shell Extension are extremely useful - in short, it can create several types of updatable symbolic link structures in standard folders for pending backup purposes.]

Freda answered 2/4, 2016 at 16:24 Comment(2)
And Link Shell Extension looks like a great tool. There's also a related light weight utility called ln.exe... even if you don't use either, you'll learn a lot just from reading the website's straightforward user guide.Ailsun
I think your edit of 2 Apr 2016 made things less clear, Clay. I think you meant something like this: "The main difference between these and 'shortcut' files is that if you... it copies the target, rather than merely the file that contains the pointer (which is what happens if you copy a shortcut file)"Mythopoeia
D
16

In addition to the excellent answer from u8it:

If anyone is interested in the difference in behavior in Windows File Explorer in Windows 10:

drag & drop to target directory:

  • symbolic link: moves the symbolic link to the target directory
  • junction: moves the original directory to the target directory

right mouse click + properties:

  • symbolic link: shows you shortcut properties
  • junction: shows you original directory folder properties

left moue click in the left pane (directory tree):

  • symbolic link: selects the original directory
  • junction: selects the junction
Diluvium answered 10/7, 2019 at 14:43 Comment(4)
The creation of Symbolic Links requires administrator privileges whereas Junctions do not.Diluvium
Windows 10 Version 10.0.17134.1130: Moving junction in explorer moves only content of original directory. Left clicking symbolic link in the tree doesn't select original directory.Rosena
This is very valuable insight, especially the junction: moves the original directory to the target directory part. I once tried to move (Ctrl+X, V) a junction once, thinking that it will just move a pointer object, but it actually removed/changed my original dir!Repudiate
@Repudiate - This unexpected behaviour of the junction must have been a bug that has been fixed. It works as expected in Windows 10 21H2 Build 19044.3086. The junction itself is moved, the target stays where it is.Tortricid
C
5

Symbolic links have been introduced very recently in Windows : as from Vista.

Symbolic links should not be regarded as an alternative to the existing NTFS "Reparse Point" technology.

Microsoft explains that the sole purpose of Symbolic links is to be more compatible with Unix.

MSDN : "Symbolic links have been designed to aid in migration and application compatibility with UNIX. Microsoft has implemented its symbolic links to function just like UNIX links."

Vista is also the firt OS to use links for its own functioning. To be compatible with legacy folder names, C:\Documents and Settings is now a link to C:\Users.

Interestingly, although Vista introduces Symbolic links, this "Documents and Settings" trick is actually a plain old junction.

Commonplace answered 1/5, 2012 at 10:52 Comment(2)
This answer doesn't say anything about the differences between symbolic links and junctions. (As such I don't think it really applies to this question at all)Wo
From Windows Vista onwards Symbolic link replaces Junctions (also, as we know, both are reparse points)Inflationary

© 2022 - 2024 — McMap. All rights reserved.