Windows: Symbolic links, junction points, whatever you want to call them, how to and why #windows

Ever run out of disk space in Windows and want to move things to a different disk, but Windows (or the application) will break?
Yes, in Linux/Unix based systems you’ve got wonderfully simple symbolic links, I’ve always wanted windows to have some of that power. Junction points in the NTFS file system are a way to achieve something close to symbolic links.
First off you need to be an administrator, if you’re user has restricted access then you are doomed. It is also worth pointing out that this isn’t for beginners, care must be taken otherwise you could break your applications or even Windows.

If you have a directory already, move the contents to the other drive. For me let’s call this “C:\dir1\bigdir”, I’ll move that to my drive that has space, “F:\”. It is worth noting that bigdir will remain empty and will be turned into the junction point. Here’s the create junction point syntax (run cmd.exe a.k.a. command prompt with administrative privileges):

CD "C:\dir1"
MOUNTVOL "bigdir" \\?\Volume{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\

What is XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ?
Run MOUNTVOL with no arguments and you will get the list of volumes.

You can also use MOUNTVOL to remove a junction point (/D option), the directory you created will remain and appear as before (empty).

So you end up with something that conceptually I’d write as “C:\dir1\bigdir” -> “F:\”.

The limitation of this is you can only link to drives.
If you want to link to a subfolder e.g. “F:\mounted_folders\bigdir” then you will need to download the Windows SDK and use a program called linkd.

For more information see How to create and manipulate NTFS junction points and Microsoft Windows Software Development Kit

Advertisements

4 responses to “Windows: Symbolic links, junction points, whatever you want to call them, how to and why #windows

  1. Apparently windows is working on a replacement for NTFS, can’t remember what it’s called.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s