NTFS junction point

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computing, an NTFS junction point is a feature of the NTFS file system that provide 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. 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.


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

[edit] Examples of use

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

[edit] Observed effects

[edit] Windows XP Professional

[edit] Windows Explorer

  • Deleting a junction point using Windows Explorer will delete the targeted files immediately as 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.

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

[edit] General

  • An infinite loop in the file structure can be created by placing a junction point in the directory it targets. (Creating this is not recommended.)
  • ACL inheritance is by design based on volumes and not working across junctions.
  • Disk free space might not show up correctly. This depends on the API call the application is using. The old style GetDiskFreeSpace() function the Windows Explorer is using does only accept the root directory of a device and will therefore only show the amount of free space of the root volume. Reparse point-aware applications use GetDiskFreeSpaceEx() to determine the free disk space of a device containing a specific directory.

[edit] Windows Vista

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

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

[edit] References

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

[edit] External links

Personal tools