NTFS junction point
From Free net encyclopedia
In computing, an NTFS junction point (JP) is a type of NTFS reparse point in the NTFS file system. It requires NTFS version 5.0 or later, which can be created (or converted from a FAT partition) using Windows 2000 or later (e.g. Windows XP). Junction Points can be used in a similar way to symbolic links - allowing you to create 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.
Note: junction points link only to folders (*). 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.
(*) This isn't 100% correct, as you can also use it to point to e.g. devices for removable media, or other filesystem partitions, and in early incarnations you could even use it to access (already authenticated) SMB shares. Unfortunately, the latter part of it was not too well though out and/or designed, and the behaviour changes even between service-pack levels.
Contents |
Warning
- NOTE: 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 Win2000 domain controllers & certain Active Directory files. See [1] for more details.
Examples of use
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.
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.
Observed effects
WinXP Pro
Explorer
- Deleting a JP using explorer is not safe - it will delete the targeted files immediately 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 sure that the Explorer handles junctions correctly. One can also use the fsutil application to delete and query reparse points (administration privileges are required).
Console
(command prompt - cmd.exe)
- 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.)
General
- Interesting tidbit: a hall of mirrors effect can be created by placing a JP in the folder it targets.
- ACL inheritance is by design based on volumes and not working across junctions.
- Disk free space might not show up correctly. This depends of the API 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 will have to use GetDiskFreeSpaceEx() to determine the free disk space of the device of a specific directory.
External links
- 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
- Codeproject Article – discussion on the source code of a junction point utility, aimed at programmers
- 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
- PC Mag Article about adding any folder to the start menu (so that you can view the contents as submenus). It links to a program [2] that achieves this using Junction points.
- Microsoft Knowledge Base Article – 'How to Create and Manipulate NTFS Junction Points'
- Link Creation Shell Extension – another windows shell extension that allows creating junction points and hard links. It provides icon overlays in the explorer and a shell column provider informs about the location a junction points to, the object ID and the number of references in the case of a hard link. Its source code is made available under the terms of the modified BSD License. The GUI may be set in Japanese or in English.