Scott Hanselman

More on Vista Reparse Points

October 03, 2006 Comment on this post [10] Posted in Longhorn | Tools
Sponsored By

SymlinkdVista upgrades NTFS to include some shiny new features, one is Transactional NTFS or "TxF". That means there's a Resource Manager for NTFS so you can batch up a whole transaction worth of file writes and if any of them go wrong - rollback.  I'm having a little trouble with Transactional NTFS right now because the resource manager is shutting down because I need to run chkdsk /f on my drive and I can't, but that's a story for another day.

Philip left a comment in my recent post on improvements in junctions/reparse points/symbolic links in Vista. He said "Have you tried using the new Vista symbolic directory link support available in the command line program "mklink /d". I have successfully used it cross-drive for other directories,though I haven't tested it in your scenario."

Soinks! That's what I get for not keeping up with Junfeng Zhang's excellent blog.

Postulate: Symlink is to Junction in Windows as Symlink is to Hardlink in Unix.

Symlinks can span volumes (wicked useful) and you can also Symlink to UNC paths. Woof. Notice the Command Prompt Screenshot at Right. In this example "My Documents" is a Symlink to another drive, while Junction points locally.

I am still a little unclear about the difference. As I understand it, junctions are "reparse points" and support links to local files and directories while symlinks are built into the NTFS file system at the Kernel level and support spanning drives. Perhaps Mark Russinovich will jump in here and explain.

Here's my DOS prompt removing my non-working junction and using the new MKLINK to get My Documents onto another drive.

Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

C:\Users\Scott>junction "My Documents"

Junction v1.04 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2005 Mark Russinovich
Systems Internals -

C:\Users\Scott\My Documents: JUNCTION
   Substitute Name: D:\Scott\My Documents

C:\Users\Scott>mklink /d "My Documents" "d:\Scott\My Documents"
Cannot create a file when that file already exists.

>junction /d  "My Documents"

Junction v1.04 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2005 Mark Russinovich
Systems Internals -

Deleted My Documents.

C:\Users\Scott>mklink /d "My Documents" "d:\Scott\My Documents"
symbolic link created for My Documents <<===>> d:\Scott\My Documents

C:\Users\Scott>junction "My Documents"

Junction v1.04 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2005 Mark Russinovich
Systems Internals -


C:\Users\Scott>dir "My Documents"
 Volume in drive C is 70 GIGS - SYSTEM
 Volume Serial Number is 88F3-D225

Newjunctionsvista1 Directory of C:\Users\Scott\My Documents

10/02/2006  09:42 PM    <DIR>          .
10/02/2006  09:42 PM    <DIR>          ..
04/23/2005  07:02 PM            37,758 0764576100.01._SCLZZZZZZZ_.jpg
...lots of files here...
...snip...I was able to CD over to another drive transparently...

Turns out I was (half) wrong when I said that Explorer doesn't know about Junctions. It knows enough about Junctions to show the shortcut icon, but that's about it. However, Explorer DOES know enough about Symlinks to show the Target (pointed to) directory in the Properties dialog. Nice.

In Vista, all kinds of things have been moved, and are now using Junctions to point to the new locations:

Was Now
Application Data AppData\Roaming
Cookies \AppData\Roaming\Microsoft\Windows\Cookies
Local Settings \AppData\Local
My Documents \Documents
NetHood \AppData\Roaming\Microsoft\Windows\Network Shortcuts
PrintHood \AppData\Roaming\Microsoft\Windows\Printer Shortcuts
Recent \AppData\Roaming\Microsoft\Windows\Recent
SendTo \AppData\Roaming\Microsoft\Windows\SendTo
Start Menu \AppData\Roaming\Microsoft\Windows\Start Menu
Templates \AppData\Roaming\Microsoft\Windows\Templates

Interesting stuff, I say.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
October 03, 2006 10:13
Junctions are based on reparse points (a more general technology) and do support linking to a directory in another drive. Junctions only work on directories though.

There are a couple new links that mklink supports, that are designed to behave similarly to UNIX:
Hard Links -- works only on files (direct link - reference count scheme) in same volume
Symbolic Links - works on both files and directories (link by name - can be broken) across volumes

Postulate should be:
Symbolic link in NTFS is same as symbolic link in UNIX.
Hard link in NTFS is same as hard link in UNIX.
Junction is similar to symbol links for directories only.

Symbolic links are the only links that work on both files and directories.
Symlinks and hardlinks have the same POSIX semantics as in UNIX. Junctions behave like classical NTFS using reparse points. (Symbolic links might also be based on reparse points)

Note: MKLINK supports options to create all three types of links
October 03, 2006 10:34
A junction appears to be much tighter binding than that of a directory symbolic link.

Based on reading, operations on the junction transparently treat it as the target directory itself. This has several implications.

So deleting a junction will affect the target directory.
But deleting a symbolic link just deletes the link itself.
(However, this is not always true, it depends on the utility awareness)

The access controls on UNIX symbolic link itself is ignored; only the target is relevant.
But those on both the source and target of a junction are important.

October 03, 2006 10:38
I found some interesting tidbits here,

The size reported by a symbolic link is actually the same as the number of characters in the path to which it points to, as if the symbolic link is a file with the name of the destination path stored in it.
October 03, 2006 11:34
Yeah, but you mention only half of the equation with TxF. Yes, you can batch up a bunch of writes. However, since the new components also communicate with MSDTC, you can have the transaction encapsulating the file writes also contain SQL Statements or any other capabilities that you have a Resource Manager for. So, I can open a TransactionScope, execute a SQL Statement and write a file, and if either fails, they both get rolled back.

IMHO, it's in this interopability where the real power lies with TxF. Also, keep in mind that transactions in TxF have full ACID semantics as well...
October 03, 2006 20:12
in your powertools page the powershell link is broken.
October 04, 2006 6:05
Scott, I don't understand why you have not been able to get junctions to work on another drive. I have about 5 junctions on my C drive pointing to my D drive. This would seem to be stranger still, since junctions are important part of Active Directory.

I am guessing that the tool you use "junction.exe" doesn't cross volumes.
However, if you use linkd.exe, you can create a junction to a different drive.

Junctions are more like symbolic links, because they refer to a path that may not exist and could be in a different drive.
October 04, 2006 8:01
Ignore my rambling. I wrote a blog post
October 04, 2006 8:26
Ya, I'm thinking my troubles have more to do with junction.exe than Vista.
October 04, 2006 23:35
It is quite possible that Junction.exe may not recognise symlinks created using the /D switch after all it was made in the 2000/XP days.
I've also found something quite baffling...
I have both of my "Music" & "Pictures" moved to my other hard disk having my older Pictures & Music. (I moved them via the Location tab of the property dialog of these "Special" folders reached via right clicking them in the Start Menu.)
I cannot understand why under Explorer the original/older folders appear to have the Vista name & icon of "Music" & "Pictures" when in fact they are still iMAGES & MUSiK when I list them using the DIR command. I've scratched my head for too long thinking maybe it's some undocumented MKLINK magic. But here's where it get's even more strange. I still see a "Pictures" & a "Music" in my user folder (which point to my older folders by the way, as expected) but they JUST DON'T SHOW UP in a DIR listing!!! I tried everything like the /ADHSL switch but "Pictures" and "Music" are nowhere to be found.
I hope you can shed some light on it. I know there is no such thing as a virtual folder (set apart junctions or symlinks) in Vista. This feature; if that's the way it was supposed to behave (as in the minds of the Vista team during the Longhorn days) it was supposedly cut from Vista. Then what do these 2 folders qualify as? :) (Reminds me of the silly sentence ending with a preposition joke!)
November 17, 2006 20:01
This is great information, however it makes it very difficult to do a CLONE with something like XXCOPY, since junctions & symlinks just repoint to the original files. XXCopy ends up copying these twice.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.