NTFS Junctions

Windows NTFS has a nice but relatively unknown feature called NTFS junctions.  It is like hard links in Unix except it is only for directories.  Microsoft has a KB article about it which points to several utilities.  However I have been using Mark Russinovich’s junction tool exclusively.

Using Junction

Usage: [-s] <directory or file name>

-s Recurse subdirectories

If you want to create or delete a junction, use Junction like this:

Usage: [-d] <junction directory> [<junction target>]

To delete a junction specify the -d switch and the junction name.

Here is an example of using junction.  Note that the order of arguments is opposite of the Unix ln command.

> junction foo d:\docs\foo

The above example will create a junction called “foo” in the current directory.  This junction will point to d:\docs\foo.

To do the same in Cygwin:

$ junction foo `cygpath -aw /d/docs/foo`

One tip is to use the DOS dir command.  It will display <JUNCTION> instead of <DIR> in directory listings for junctions.

Leave a Reply

Your email address will not be published. Required fields are marked *