NTFS junction point
Encyclopedia
An NTFS junction point is a feature of the NTFS
NTFS
NTFS is the standard file system of Windows NT, including its later versions Windows 2000, Windows XP, Windows Server 2003, Windows Server 2008, Windows Vista, and Windows 7....

 file system
File system
A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...

 that provides the ability to create a symbolic link
Symbolic link
In computing, a symbolic link is a special type of file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symbolic links were already present by 1978 in mini-computer operating systems from DEC and Data...

 to a directory
Directory (file systems)
In computing, a folder, directory, catalog, or drawer, is a virtual container originally derived from an earlier Object-oriented programming concept by the same name within a digital file system, in which groups of computer files and other folders can be kept and organized.A typical file system may...

 which then functions as an alias of that directory. This has many benefits over a Windows shell
Windows Shell
The Windows shell is the main graphical user interface in Microsoft Windows, and since Windows 95 hosted by Windows Explorer. The Windows shell includes well-known Windows components such as the Taskbar and the Start menu...

 shortcut
Computer shortcut
A file shortcut in Microsoft Windows is a small file containing a target URI or GUID to an object, or the name of a target program file that the shortcut represents. The shortcut might additionally specify parameters to be passed to the target program when it is run. Each shortcut can have its own...

 (.lnk) file, such as allowing access to files within the directory via Windows Explorer
Windows Explorer
This article is about the Windows file system browser. For the similarly named web browser, see Internet ExplorerWindows Explorer is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface...

, the Command Prompt, etc.

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

Junction points are a type of NTFS reparse point
NTFS reparse point
An NTFS reparse point is a type of NTFS file system object. It is available with the NTFS v3.0 found in Windows 2000 or later versions. Reparse points provide a way to extend the NTFS filesystem by adding extra information to the directory entry, so a file system filter can interpret how the...

; they were introduced with NTFS 3.0, the default file system for Windows 2000
Windows 2000
Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...

 (Windows NT 5.0). The Windows 2000 and Windows 2003 Resource Kit
Resource Kit
Resource Kit is a term used by Microsoft for a set of software resources and documentation released for their software products, but which is not part of that product...

s include a program called linkd, to create junction points; Mark Russinovich
Mark Russinovich
Mark E. Russinovich is a Technical Fellow in the Platform and Services Division at Microsoft. He was a cofounder of software producers Winternals before it was acquired by Microsoft in 2006.-Early life and education:...

 of Winternals released a tool called junction which provided more complete functionality. Windows XP includes fsutil reparsepoint. Windows NT 6.0
Windows NT 6.0
Windows NT 6.0 can refer to these releases of Microsoft Windows:*Windows Vista*Windows Server 2008*Windows Small Business Server 2008...

 and later operating systems include an mklink command-line utility for creating junction points.

Warning

  • Microsoft
    Microsoft
    Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

     strongly recommends:
    • Use NTFS
      NTFS
      NTFS is the standard file system of Windows NT, including its later versions Windows 2000, Windows XP, Windows Server 2003, Windows Server 2008, Windows Vista, and Windows 7....

       ACLs
      Access control list
      An access control list , with respect to a computer file system, is a list of permissions attached to an object. An ACL specifies which users or system processes are granted access to objects, as well as what operations are allowed on given objects. Each entry in a typical ACL specifies a subject...

       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 Windows 2000
    Windows 2000
    Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...

     domain controllers & certain Active Directory files.

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 exactly the 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 partition
Disk partitioning
Disk partitioning is the act of dividing a hard disk drive into multiple logical storage units referred to as partitions, to treat one physical disk drive as if it were multiple disks. Partitions are also termed "slices" for operating systems based on BSD, Solaris or GNU Hurd...

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

Obtaining a list of junction points

A list of all the junctions present on a disk volume can be obtained from an elevated Command Prompt as Admin by executing "dir /aL /s C:\", where "C:" is the volume to scan.

Windows Explorer

  • Deleting a junction point using Windows Explorer
    Windows Explorer
    This article is about the Windows file system browser. For the similarly named web browser, see Internet ExplorerWindows Explorer is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface...

     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
    Windows 2000
    Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...

     or later recognizes junction points, displaying instead of in directory listings (use dir
    Dir
    -Acronyms:* Detroit International Riverfront, an area of Detroit, Michigan that borders the Detroit River* Developmental, Individual differences, Relationship-based approach, a developmental intervention to autism developed by Stanley Greenspan and Serena Weider....

     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
    Del (command)
    In computing, del is a command in various DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to delete one or more files or directories from a filesystem. It is analogous to the Unix rm command...

     myjunction
    should not be used — this will just delete all the files in the targeted directory.
  • The commands rmdir
    Rmdir
    rmdir is a command which will remove an empty directory on a Unix, DOS, OS/2 or Microsoft Windows operating system. In Unix, Linux, and MacOS, it is case sensitive, whereas DOS, OS/2 and Windows , you can type the characters in any combination of upper case and lower case letters, and rd/rmdir...

     and move
    Move (command)
    In computing, move is a command in various DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to move one or more files or directories from one place to another. The original file is deleted, and the new file may have...

     work fine with junctions, with the caveat that move won't let the junction move to another volume (as opposed to Windows Explorer
    Windows Explorer
    This article is about the Windows file system browser. For the similarly named web browser, see Internet ExplorerWindows Explorer is a file manager application that is included with releases of the Microsoft Windows operating system from Windows 95 onwards. It provides a graphical user interface...

    , as mentioned above.)
  • The rmdir
    Rmdir
    rmdir is a command which will remove an empty directory on a Unix, DOS, OS/2 or Microsoft Windows operating system. In Unix, Linux, and MacOS, it is case sensitive, whereas DOS, OS/2 and Windows , you can type the characters in any combination of upper case and lower case letters, and rd/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.
  • Windows XP and above, fsutil reparsepoint delete safely deletes junction points.
  • The command attrib myjunction appended with -s -h -a -r will not work on a junction.

General

  • An infinite loop
    Infinite loop
    An infinite loop is a sequence of instructions in a computer program which loops endlessly, either due to the loop having no terminating condition, having one that can never be met, or one that causes the loop to start over...

     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\%USERNAME%\AppData\Local\Application Data". Here "Application Data" is a junction that points to "C:\Users\%USERNAME%\AppData\Local\" for compatibility with legacy applications.
  • ACL inheritance is by design based on volumes and not working across junctions.

Windows in common

Junction points are useless on removable media, even when they redirect to itself.
The reason is that the target destination is converted to an absolute path (including drive letter) and stored on the destination point.
On another computer the drive will be normally mapped on a different drive which results in void links.
To avoid this misbehavior you must use symbolic links to directories, which is restricted on Windows Vista/7 to administrators.

Windows Explorer

  • Junction points are indicated with a shortcut 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.

Unlike a junction point, a symbolic link can also point to a file or remote SMB
Server Message Block
In computer networking, Server Message Block , also known as Common Internet File System operates as an application-layer network protocol mainly used to provide shared access to files, printers, serial ports, and miscellaneous communications between nodes on a network. It also provides an...

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.

External links

  • Microsoft Knowledge Base Article – 'How to Create and Manipulate NTFS Junction Points'
  • Junction command line utility from Microsoft TechNet
  • Codeproject Article – discussion on the source code of a junction point utility, aimed at programmers
  • PC Mag Article about adding any directory to the start menu (allowing a preview within the startmenu as a submenu).
  • Link Shell Extension - free software to work with junctions, hard links, symbolic links and more complex features like Hardlink Clones and Symboliclink Clones.
  • GetFoldersize - free software to list all junctions, hard links and symbolic links on your hard drive.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK