NTFS junction point

From Wikipedia, the free encyclopedia

An NTFS junction point (JP) is a feature of the NTFS file system version 3.0 or later. It is a type of NTFS reparse point. Junction Points can be used in a similar way to symbolic links — allowing the creation of a link to a folder that is, for most intents and purposes, the same as the folder itself. This has many benefits over a Windows shell shortcut (.lnk) file, such as allowing you to access files within the shortcut via explorer, the console, etc.

Junction points can only link to folders and volumes. You can create a similar link to a file, but with the restriction that the file must belong to the same logical volume, using hard links.

Contents

[edit] Warning

  • Microsoft strongly recommends:
    • 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 your junction points at a secure location in a namespace where you can test them out in safety, 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.[1]

[edit] Examples of use

[edit] Program redirection

By setting a JP that points to a directory containing a particular version of a piece of software, you can, in most cases, seamlessly add another version of the software and redirect the JP to point to the version you wish to use.

[edit] Space saving

If you are running out of space on a drive, you can move those files to a new drive - but this can cause some problems with old links, configuration files, registry, etc. By creating a JP at the previous location (pointing to the new location) Windows will treat it the same as if the directory still exists there, redistributing the load to the filesystem with more space.

[edit] Issues

Often it is difficult to delete JPs.

[edit] Observed effects

[edit] Windows XP Professional

[edit] Windows Explorer

  • Deleting a JP using explorer is not safe — it will delete the targeted files immediately as if using shift-delete.
  • Beware: if the JP is sent to the recycle bin, the targeted files will look safe, but will be deleted when the recycle bin is emptied.
  • Moving the JP to a different location on the same drive only moves the JP, however moving to another drive turns the JP into a normal folder and moves all files there (leaving the targeted directory empty).
  • Whilst walking through the directory with explorer, it seems impossible to delete folders, however files can be deleted.
  • A solution for these issues is installing NTFS Link (see external links section), which makes Windows Explorer handle junctions correctly. One can also use the fsutil application to delete and query reparse points (administration privileges are required).

[edit] Console

On the cmd.exe command prompt:

  • The dir command in Windows 2000 or later recognizes junction points, displaying <JUNCTION> instead of <DIR> in directory listings.
  • Any commands that would normally affect files inside a normal directory will act the same here, so don't use del myjunction — this will just delete all the files in the targeted folder.
  • rmdir & move seem to work fine with junctions, with the caveat that move won't let you move the junction to another volume (as opposed to Windows Explorer, as mentioned above.)
  • rmdir seems safe in that it only deletes the JP, not the targeted files.
  • Whilst walking through the directory with the console, files can be deleted, but unlike explorer, directories can also be deleted (using rmdir/s dirname for example.)
  • Windows Vista no longer uses rmdir, but still has rd.
  • Using the linkd command with the /d switch is a safe way to delete junction points.

[edit] General

  • Interesting tidbit: an infinite loop in the file structure can be created by placing a JP in the folder 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 the device of a specific directory.

[edit] Windows Vista

Windows Vista supports a new NTFS symbolic link capability that replaces junction points in Windows 2000 and Windows XP. Microsoft has implemented its symbolic links to function just like UNIX links. They are designed to aid in migration and application compatibility with UNIX operating systems.

[edit] External links

[edit] Informative

[edit] Other

  • Junction Link Magic – Windows graphical interface for creating, updating and deleting junction points
  • Winbolic Link – Windows graphical interface for creating, updating and deleting junction points and shortcuts
  • NTFS-Link – Windows shell extension that allows creating junction points and hard links. Existing junction points and hardlinks get marked by a small additional icon in the explorer.
  • Junction – command line utility with source code
  • Hardlink Shell Extension – adds new entries for managing hardlinks and junctions into the Windows Explorer context menus
  • Link Creation Shell Extension – another windows shell extension that allows creating junction points and hard links.