CXO

Get IT Done: Manage local files and folders more easily with drive mounting and hard links

Use mounted drives and hard links to manage shared files and folders


Although I normally recommend that users store their files on a network server so that the data is centrally located and regularly backed up, in some environments this just isn't practical. For example, your organization might have many laptop users who spend most of their time away from the network, or you may work for a small organization that lacks a file server. When local storage is all you have to work with, mounted drives and hard links can make your users' lives a little easier.

Mounted drives
Drive mounting allows a volume that physically resides in one location to appear to exist within another location. If you have ever worked with a distributed file system (Dfs), you've seen a form of drive mounting in action. In Dfs, a drive letter is usually mapped to the Dfs root. Share points from a variety of servers appear as subfolders beneath this root. The idea is that although the share points are scattered across multiple servers, they appear to Dfs users as though they all exist within the same file system.

Drive mounting works similarly to this concept, but at a lower level. Instead of creating a Dfs root that is universally accessible, drive mounting works locally. This process allows you to select either a local or a networked location and have that location appear to exist within the location of your choice.

For example, while recently compiling my home movies, I needed to store 10 2-GB files. Because this would be a total of 20 GB, I didn't want to store the data on the same volume on which I normally store my movies. Instead, I wanted to store the files on a different volume that had lots of free disk space. Unfortunately, my video editing software always looks to a specific folder for source files.

My solution to this problem was to implement a mounted drive. To do so, I entered the diskmgmt.msc command at Windows XP's Run prompt. This opened the Disk Management Console, shown in Figure A.

Figure A
You can mount drives from Windows XP's Disk Management Console.


In this particular case, I wanted to make drive D: appear as though it existed within my video editing folder. So I went into My Computer, navigated to my video editor's working directory, and created a new folder beneath this directory called Boats. I then went back into the Disk Management Console, right-clicked on my D: drive, and selected the Change Drive Letter And Paths command from the shortcut menu.

In the Change Drive Letter And Paths dialog box, I clicked Add. Windows gave me an option to change the drive letter or to mount the drive within an empty NTFS folder. I chose the NTFS folder option, clicked the Browse button, and navigated to the Boats folder. By clicking OK, I set the selected path to point to the D: drive. As you can see in Figure B, the D: drive can now be referenced either as D: or as C:\Video\data\boats.

Figure B
The D: drive can now be accessed as either D: or as C:\Video\data\boats.


If you look at Figure C, you'll notice that I've used Windows Explorer to navigate to the C:\Video\data\boats folder. As you can see, this folder is redirected to the root directory of the D: drive. Obviously, I wouldn't want to save video files in the root directory. However, I could easily create a subdirectory within this folder and save my video files within it.

Figure C
The C:\Video\data\boats folder points to the D: drive's root directory.


Hard links
You can also use hard links to help your users manage their hard drives. A hard link is similar to a shortcut, but it gives the illusion of being the actual file rather than being a shortcut to the file. You can use hard links to give a user easier access to a file that is buried deep within the user's drive file structure. For example, you might create a hard link to a file within the My Documents folder so that a user can access all of his or her data files from a common location. You can create a hard link that creates a file with the original filename but in a different directory. You can also create a file with a different filename that exists in either a different directory or in the same directory as the original file.

Before I show you how to create a hard link, there are a few things you need to know about them. First, hard links do not have security descriptors. If you want to make a change to a security permission, you must make the change on the original file, not to the hard link. In addition, a hard link can't reference a file that exists on a different volume; it can point only to a file that is on the current volume. Furthermore, the volume must be formatted as NTFS.

Another peculiarity is that if you modify the original file directly, the date/time stamp and the file size of the hard link will not change. This information changes only when you modify the file by accessing it through the hard link. Finally, it's important to note that deleting the file that a hard link points to does not remove the hard link. You must manually delete a hard link after deleting the original file.

There is no GUI option for creating hard links. You must create them from the command line using the fsutil hardlink create command. The syntax is as follows:
 
fsutilhardlink create <new filename> <existing filename>

For example, you could do something like this:
 
fsutilhardlink create C:\Program files\video\data\boats\vid.avi c:\my documents\vid.avi

This would create a hard link to the C:\Program Files\Video\Data\Boats\VId.avi file in the C:\My Documents folder.

Editor's Picks

Free Newsletters, In your Inbox