Tuesday, November 23, 2010

Symbolic links on Windows

 I can't deny that this is not something most users will ever need. Nevertheless, I thought worthy to comment about as some issues from original sources are still to be fixed, so this might help people stuck in the same kind of problems.

The symlinks (symbolic links) or junctions as more commonly called in Windows (actually this is NTFS's junction point), are simple files or directories that actually are localed in some place else. The only difference here from usual links you can create on your desktop, for example, is the fact that all software (most of them) use the link location as if it was the real file. This is very handy in cases you want to move specific directories or files into other drives on your computer. Although Windows do not officially added support for NTFS junctions, it has released some official tools to handle it.

A classic case here for me is the virtual machine. Trying to update the latest version of the iPad, I need to run a backup first, which takes nothing less than 10~20GB of my virtual hard drive (thank you iTunes - I am being sarcastic btw)... my solution here then is to simply create a new temporary virtual drive just for this task (don't ask me how long this takes).

Junction application

You need to install (my suggestion is to save the file into c:\Windows\system32\, which will make the command available anywhere from the command-line) the junction application from Microsoft SysInternals: http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

Do not follow the instructions of usage there, because they are incorrect (well, as far as this post date). I have sent a message to them to fix it, but only almighty knows when or if this is going to happen.

Junction commands

Creating

just go to the path where you want to create the junction (from command-line)

c:\> junction iTunes h:\iTunes

(here I am setting the real files of iTunes directory to be in H drive)

Note: The local iTunes file/directory is going to be created by the junction application, so DO NOT create a real file with the same name here in advance (as specified in official documentation).

Searching


c:\> junction -s

(this will search and list for all junctions available in C drive)

Removing

c:\> junction -d iTunes 

But...

The only bad side here is that this action really happens in the file system level, leaving Windows dumb to deal with them (in Windows Explorer, you will just see it as another directory like any other)... forgetting about what you did may give you some headaches later, so I usually write a README file to really remember me about something unusual I have done in that particular location.

2 comments:

  1. Yo!

    I've thought of using NTFS junction points for side-by-side deployment in Windows, but never actually did it because all our company software is running on Linux now. But it's nice to know a friend has looked into it (and blogged about it)!

    Cheers!!

    ReplyDelete
  2. Yeah, well, what I did was just a simple thing, but still thought worth mentioning! It works great!

    ReplyDelete