HOME
TOPICS
ABOUT ME
MAIL

 
By using a hard link, a folder on one drive can appear to be on another drive.
  technofile
Al Fasoldt's reviews and commentaries, continuously available online since 1983

Free Win XP and Win 2000 software creates hard links, making folders on one drive nest into the folders on another one


April 28, 2002


By Al Fasoldt
Copyright © 2002, Al Fasoldt
Copyright © 2002, The Post-Standard

   A few months ago I realized I was running out of space on my main drive on my Windows 2000 PC. The secondary drive on my PC had a lot of room, so I moved 500 megabytes of files and their folders over to the other drive.
   Normally, any Windows user who does this kind of thing is a loon. Under Windows, programs can't be moved to new locations without a lot of work resetting all the pointers that Windows and the programs themselves use all the time. The all-important settings in the Windows Registry would no longer work right, either. Programs either wouldn't run at all or would complain that they couldn't find their files. They might even pop up warning windows that tell you your software is no longer registered or no longer "legal."
   But when I moved all those files and folders -- more than 200 programs in total -- all of them worked without complaint. Windows didn't mind at all, and everything was fine.
   How did I perform this trick? If you've used Windows for as long as I have, you might wonder if I asked for divine intercession. But nothing so drastic was needed. I used a free program called Junction.
   Junction, from www.sysinternals.com/ntw2k/source/misc.shtml, activates an almost hidden function of Windows 2000 and Windows XP. Both of them can use "hard links" (sometimes called junctions) to make remote drives and folders appear to be part of a "local" drive. Unix and Linux computers, including the newest Apple Macintoshes, can make extensive use of hard links, but they're rare in Windows.
   Hard links require the advanced Windows file system known as NTFS. I wrote about some of the advantages of NTFS last week. This is yet another. You can convert your standard Windows 2000 or Windows XP file system to NTFS easily.
   By using a hard link, a folder on one drive can appear to be on another drive. A folder that normally is located in the "Program Files" folder of a Windows C: drive might actually be on the D: drive, for example. The hard link would make Windows and all the software running under Windows see the folder in the "fake" location.
   I took advantage of this to move all those programs to the D: drive. First, I made sure Windows wasn't running any of the programs I wanted to relocate. Then I moved all the programs I wanted to relocate by dragging their folders -- this, of course, meant that all their files were carried along for the ride -- from the "Program Files" folder on C: to a new folder named "Program Files" on the D: drive.
   That freed up a lot of space on the C: drive, of course, but it left all those programs as orphans. They wouldn't run right if I dared to double click on any of them.
   But I had one more step. Listen carefully. Here comes the semi-secret tip that will make your friends (and your know-it-all kids) think you're a whiz.
   I ran Junction -- it's a command-line program that runs in a command window (like a DOS program, in other words) -- and created hard links from the D: drive folders I'd just moved to the C: drive. I typed the proper commands and that was that. It took only a couple of minutes.
   Here's the basic idea of what I did. The folder called "Winning at Bridge" that I had moved to the "Program Files" folder on D:, for example, suddenly appeared to Windows to be located on the C: drive. The folder called "Time Trial" in the Program Files folder on D: appeared to exist in the Program Files folder on C:, and so on. (Actually, Windows saw two locations for each hard-linked folder, one on the C: drive and one on the D: drive. It thought both were legitimate, but that didn't get in my way as long as I remembered that I would see these duplicates while searching for files.)
   Junction isn't hard to use, but it's not for anyone who is worried about making changes to a computer system. I'm not responsible if you mess up your files. Junction shows a short explanation of how to use it when you run it without giving any command parameters, so all you have to do is place it in your main Windows folder -- this folder is called WINNT on my Windows 2000 computer, but yours might be different -- and then type "JUNCTION" and press Enter from a command prompt. If you know how to use batch files to make this sort of thing easier, just make a batch file called JU.BAT and have it call Junction for you.

   Claus Reibenstein wrote on June 7, 2006 to tell me I was wrong:
   "This article contains a big error: It does not handle hard links at all. It only handles junctions, but calls them hard links. This is wrong. Hard links and junctions are two completely different things. A hard link can NOT cross partition boundaries, and hard links can only be set on files, not on folders."
   
   Note that my tests of Junction showed that it did, indeed, do what I said it did. The terminology in Windows 2000 and XP, which were designed without regard to standards for establishing hard links, can be argued for years. But the performance is just as I described.