windows NTFS 连接点和符号链接有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9042542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:09:37  来源:igfitidea点击:

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

windowssymlinkntfs

提问by Billy ONeal

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

在高层次上,NTFS 连接点符号链接之间唯一明显的区别是连接点只能是目录,而符号链接也可以作为目标文件。

What other differences between the two exist?

两者之间还存在哪些其他差异?

(Note, I've already seen this questionand 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)

(注意,我已经看过这个问题,我要找的有点不同——这个问题是在寻找一个利弊列表,我正在寻找一组技术差异)

回答by u8it

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).*

**速度/复杂性差异的声明来自维基百科条目中关于 NTFS 重解析点的未经验证的声明(很好读)。*



Other NTFS Link Comparisons

其他 NTFS 链接比较

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

来自MKLink 上的 SS64 页面

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 连接和 NTFS 符号链接实际上以相同的方式(重解析点)做同样的事情,除了前面提到的它们处理方式的差异。事实上,从技术上讲,一个 Junction 是一个更一般意义上的“符号链接”,有时文档可能将一个 Junction 称为符号链接,就像这里的情况一样。在这种情况下,“符号链接”并不意味着与结点不同的 NTFS 符号链接(见下文)。

NTFS

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.

尽管 OP 指定了这一点,但值得指出的是,“符号链接”是一个非常笼统的术语,并非特定于 NTFS。因此,具体而言,此比较是关于 NTFS 连接与 NTFS 符号链接。

回答by James Manning

The places I find the most useful for the differences:

我发现对差异最有用的地方:

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

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

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

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

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

假设:Symlink 在 Windows 中与 Junction 的关系就像 Symlink 在 Unix 中与 Hardlink 的关系一样。

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

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.

Windows 7 和 Windows Vista 使用命令行实用程序 mklink 支持文件和目录的符号链接。与连接点不同,符号链接还可以指向文件或远程服务器消息块 (SMB) 网络路径。此外,NTFS 符号链接实现提供对跨文件系统链接的全面支持。但是,启用跨主机符号链接的功能要求远程系统也支持它们,这有效地限制了它们对 Windows Vista 和更高版本的 Windows 操作系统的支持。

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

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.

Windows 创建的符号链接与目录连接非常相似,但与目录连接不同的是,它可以指向文件或远程网络文件或目录。目标可以定义为相对于符号链接位置的路径,或当前卷或另一卷中的绝对路径。另请注意,文件的符号链接不同于目录的符号链接,目标必须与定义匹配。

回答by Techno Wizard

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.)

在功能上,在 Windows 中,一旦创建,就没有真正的区别。但是,它们之间在可以做什么方面存在显着差异。联结只能用于创建指向文件夹的链接,无论是在同一驱动器还是不同的驱动器上,但前提是这些驱动器位于本地系统上(您不能通过网络创建指向文件夹的联结链接。)符号链接但是,没有相同的限制。符号链接可用于链接到文件或文件夹,这些文件或文件夹可以位于同一系统(同一驱动器或不同驱动器)或网络共享上,并且可以使用相对位置符号(“\\system2 \foldera\file.txt", "d:\foldera\file.txt", "\\system2\foldera", "d:\foldera" 或 "d:\foldera\folderb.."

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.

总结一下:连接点仅限于本地系统上的文件夹,而符号链接可以创建指向可通过 UNC 路径或本地系统访问的文件夹或文件的链接,在如何指定这些位置方面具有更多功能。符号链接基本上是连接点和硬链接的更通用的替代品。此外,在创建跨平台 UNC 路径链接时,符号链接与 Unix 和 Linux 兼容。

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

希望这能以令人满意的方式回答您的问题。编辑以更正印刷错误。

回答by Clay

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.

链接外壳扩展http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html是创建和查看多种链接的绝佳工具。它还具有出色的文档。

[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.]

[在完整安装中,如果您正在查看高级链接,它会添加一个新的属性选项卡。At 还为各种链接类型添加了图标覆盖箭头 - 如果这些未显示,请滚动到常见问题部分;Windows 仅支持 13 个叠加层;他展示了一个注册表解决方法。其信息有用性的一个示例:未成功尝试获取您认为是文件夹的权限,但实际上是系统提供的连接链接,通常用于与旧版本的 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

它们在网络上的行为不同。此链接描述了此行为: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.]

如果您认为 Junction Links 是“在位置方面愚弄操作系统的快捷方式”,那么您将对它们的使用以及破坏它们的原因有一个很好的实际比喻。主要区别在于,如果您复制符号链接或连接点,它会复制目标,而不是(如快捷方式)仅包含指针的文件。与快捷方式一样,您可以在不删除目标文件/文件夹的情况下删除符号或连接链接。[硬链接,文件只有在删除最后一个链接时才会被删除 - 包括从回收站中删除。查看 LSE 中任何这些链接的属性标签,以查看硬链接的目标或引用计数。]

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.

硬链接或快捷方式是唯一可以移动而不会产生诸如破坏或复制整个目标的副作用的链接类型。移动目标总是会断开链接,尽管它们可以在属性选项卡(用 LSE 显示)中轻松更新或重新创建,如果复杂,可以使用 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).]

符号链接的创建需要管理员权限,而连接则不需要。这加上对 Junction 的广泛的内部操作系统使用表明 Windows 以一种直观的、预期的方式处理它们。[一定要警惕来自系统文件夹的意外副作用(根据 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.]

[Link Shell Extension 的某些特定于备份的功能非常有用 - 简而言之,它可以在标准文件夹中创建多种类型的可更新符号链接结构,用于待定备份目的。]

回答by Philip

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

最近在 Windows 中引入了符号链接:从 Vista 开始。

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

符号链接不应被视为现有 NTFS“重解析点”技术的替代品。

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

微软解释说,符号链接的唯一目的是与 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."

MSDN:“符号链接旨在帮助迁移和与 UNIX 的应用程序兼容性。Microsoft 已实现其符号链接,使其功能与 UNIX 链接一样。

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

Vista 还是第一个将链接用于其自身功能的操作系统。为了与旧文件夹名称兼容,C:\Documents and Settings现在是指向C:\Users.

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

有趣的是,虽然Vista 引入了Symbolic links,但这个“ Documents and Settings” 把戏其实是一个普通的老式连接器。

回答by Jinjinov

In addition to the excellent answer from u8it:

除了来自 u8it 的优秀回答:

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

如果有人对Windows 10中Windows 文件资源管理器的行为差异感兴趣:

drag & drop to target directory:

拖放至目标目录:

  • symbolic link: moves the symbolic linkto the target directory
  • junction: moves the original directoryto the target directory
  • symbolic link: 移动symbolic link到目标目录
  • junction: 移动original directory到目标目录

right mouse click + properties:

鼠标右键+属性:

  • symbolic link: shows you shortcut properties
  • junction: shows you original directoryfolder properties
  • symbolic link: 显示快捷方式属性
  • junction:显示original directory文件夹属性

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

在左窗格中单击鼠标左键(目录树):

  • symbolic link: selects the original directory
  • junction: selects the junction
  • symbolic link: 选择 original directory
  • junction: 选择 junction