28 Aug 2011

Hardlinks instead of shortcuts

This is a good IT tip for people who want to save hard disk space, in situations when you have a large file that needs to be in two folders.

Normally if you duplicate a file to another folder in Windows you will use double the space. Makes sense doesn’t it. Some will know that you can use what are known as ‘shortcuts’. However, there a significant problem with shortcuts. Sometimes if you rearrange your files or add new drive letters the ‘shortcuts’ may not work.

One solution to this is to create ‘hardlinks’. You can only do this on NTFS formatted hard drives. The hardlink points to a particular file space. You can have different file names in different folders pointing to the same file – using the one file space on the drive. This is not what you may imagine to be a ‘shortcut’ – as will become apparent.

You can then merrily do what you want with the file in either folder. So if you have a file in C:\Test1\file.doc and C:\Test2\file2.doc, both of those file names in different directories, point to the same file content, although they appear to have different names. Yes - you can merrily rename them to whatever you wish in either folder but the file space on the drive will be for one file only. You can put them in any other directory. Editing the file in one folder leads to the file in the other folder changing to suit simply because the file actually has two names! The only way to delete the file is to delete it from the two folders.

So – a shortcut points to one file whereas hardlinks can represent two files. (I’m keeping it simple)

Right – so you’re wondering how the heck you can do all this. There is a very nice Windows App both 32bit and 64bit versions that can be used. Click Hard Link Shell Extension. Hey, this thing will not read your mind and download to your brain how to use it. So – please read the information available very carefully. It isn’t idiot-proof so practice using it on some file that you can throw away.

This is very powerful stuff. You can also do wonderful things with folders, create symlinks, junctions and a bunch of other cool stuff. Beginners should start with just any old test file. See the bumpf below. If in doubt backup your hard drive before trying out the application. I accept no liability for loss of data. It’s not that it is dangerous. But if you end up loosing data please don’t blame me. Power without control is a nonsense – always remember that.