NTFS junction point: Wikis

  

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

From Wikipedia, the free encyclopedia

In computing, an NTFS junction point is a feature of the NTFS file system that provides the ability to create a link to a directory that is, for most intents and purposes, the same as the directory itself. This has many benefits over a Windows shell shortcut (.lnk) file, such as allowing access to files within the directory via Windows Explorer, the Command Prompt, etc.

Junction points can only link to directories on a local volume; junction points to remote shares are unsupported.[1]

Junctions points are a type of NTFS reparse point; they were introduced with NTFS 3.0, the default file system for Windows 2000 (Windows NT 5.0). The Windows 2000 and Windows XP Resource Kits include a program called linkd to create junction points; Mark Russinovich of Winternals released a tool called junction which provided more complete functionality. Windows NT 6.0 and later operating systems include an mklink command-line utility for creating junction points.

Contents

Warning

  • Microsoft strongly recommends[2]:
    • Use NTFS ACLs to protect junction points from inadvertent deletion.
    • Use NTFS ACLs to protect files and directories targeted by junction points from inadvertent deletion or other file system operations.
    • Never delete a junction point using Explorer, a del /s command, or other file system utilities that walk recursively into directory trees. These utilities will affect the target directory and all subdirectories. Instead, use the utilities described below to delete junction points.
    • Use caution when applying ACLs or changing file compression in a directory tree that includes NTFS Junction Points.
    • Do not create namespace cycles with NTFS or DFS junction points.
    • Place all junction points at a secure location in a namespace where they can be tested safely, and other users will not mistakenly delete them or walk through them.
  • Obscure: There are issues relating to junction points on MS Windows 2000 domain controllers & certain Active Directory files.[3]

Examples of use

Program redirection

By setting a junction point that points to a directory containing a particular version of a piece of software, it may be possible to add another version of the software and redirect the junction point to point to the version desired.

Avoiding manual file synchronization

Sometimes you may require that two directories have the exact same contents. If a separate directory is created for this, the two directories must also be kept in sync. Using an NTFS junction instead of a second directory can avoid this.

Saving disk space

Since the contents of a junction do not take up any space (they simply point to the original files in the original directory) if you need to have multiple points of entry to a large directory, junction points will serve that purpose well. Do not confuse junction points with a copy of something as it simply points to the original. If directories need to be modified separately a junction cannot be used as it does not provide a distinct copy of the directory or files within.

Circumventing pre-defined paths

Since reinstalling Windows (or installing a new version) often requires deleting the contents of the C: drive, it is advantageous to create multiple partitions so only one partition needs to be deleted during the installation. However, some programs don't let the user choose the installation directory, or install some of their files to the C: drive even when they are installed to a different drive. By creating a junction point, the program can be tricked into installing to a different directory.

Observed effects

Windows XP Professional

Windows Explorer

  • Deleting a junction point using Windows Explorer will delete the targeted files immediately if using shift-delete.
  • If the junction point is sent to the Recycle Bin, the targeted files will look safe, but will be deleted when the Recycle Bin is emptied.
  • Moving the junction point to a different location on the same drive only moves the junction point. However, moving it to another drive turns the junction point into a regular directory and moves all files there (leaving the original targeted directory empty). Undoing the move puts the junction directory and its contents back on the original drive, but the original targeted directory is still empty (that is, the junction is not recreated).
  • While walking through the directory with Windows Explorer, use shift-delete to delete directories, however files can be deleted normally. Disabling the recycle bin for the drive hosting the junction point will allow regular deletion of folders.

Command Prompt (cmd.exe)

  • The dir command in Windows 2000 or later recognizes junction points, displaying <JUNCTION> instead of <DIR> in directory listings (use dir with the /A or /AL command-line switch).
  • Any commands that would normally affect files inside a normal directory will act the same here. Thus the command del myjunction should not be used — this will just delete all the files in the targeted directory.
  • The commands rmdir and move work fine with junctions, with the caveat that move won't let the junction move to another volume (as opposed to Windows Explorer, as mentioned above.)
  • The rmdir command is safe in that it only deletes the junction point, not the targeted files.
  • Whilst walking through the directory with the command line interface, files can be deleted, but unlike explorer, directories can also be deleted (using rmdir /s dirname for example.)
  • Using the linkd command with the /d switch is a safe way to delete junction points.

General

  • An infinite loop in the file structure can be created by placing a junction point in the directory it targets. This can confuse some tools which scan entire directory trees but do not check for junctions, such as Antivirus tools, which end up recursing until they crash or create a path name longer than 255 characters which causes a Windows API error and stops the recursion. Windows Vista and Windows 7 have an example of this in C:\Users\<user name>\AppData\Local. The "Application Data" junction points to "Local" for compatibility with legacy applications.
  • ACL inheritance is by design based on volumes and not working across junctions.

Windows Vista

Windows Explorer

  • Junction points are indicated with an arrow icon overlay.
  • Deleting a junction point using Explorer is now safe.
  • A junction point can be restored from the recycle bin.

Symbolic link

Windows Vista supports a new symbolic link capability that replaces junction points in Windows 2000 and Windows XP. They are designed to aid in migration and application compatibility with UNIX operating systems.[4]

Unlike a junction point, a symbolic link can also point to a file or remote 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.

References

  1. ^ Sysinternals Junction documentation
  2. ^ "How to create and manipulate NTFS junction points". Microsoft. http://support.microsoft.com/kb/205524. Retrieved 2007-08-08. 
  3. ^ Neohapsis.
  4. ^ "Symbolic Links". MSDN. http://msdn2.microsoft.com/en-us/library/aa365680.aspx. Retrieved 2007-07-20. 

External links








Got something to say? Make a comment.
Your name
Your email address
Message