Demystifying USMT Hard Link Migration
2010-10-22 Leave a comment
It was a bit tough to wrap my head around the whole concept of hard link migration in USMT. In the past, if I wanted to re-image a user’s machine, I needed to safeguard all the user’s precious data first. I might store their documents on a network server, or removable storage. Once I’d done that, I would rebuild their machine, and then restore the user data from it’s temporary vault. Problem was, all this data transfer took time. If the user had a lot of local data, it could take a very long time.
Enter User State Migration Tool’s great Hard Link Migration feature. Hard Link Migration takes advantage of a feature of the NTFS file system known as hard links. What USMT does when a system is re-imaged might seem like a bit of wizardry, but it’s really not.
Try this experiment.
On your Windows 7 or Windows Server 2008 computer, drop to the command prompt and change directory to the root of drive C:\. I suggest the root of C: simply because it means you don’t have to type such long paths at the prompt, but you could create these folders on any NTFS volume.
First create two new folders;
C:\>md old
C:\>md new
The “old” folder will represent the user data on the old computer. The “new” folder will represent a temporary and protected folder that the hard links will be stored in.
Next, create a test file in the “old” directory
C:\>cd old
C:\old>echo “This is so cool!” > Test.txt
C:\old>type test.txt
“This is so cool!”
This created a file in the folder that contained the text “This is so cool!”
Next change to the “new” folder. In this folder we are going to create the “hard links” that will be protected from deletion during the reinstallation of the OS.
First, we’ll take a look at the syntax of the “mklink” command.
C:\new>mklink /?
Creates a symbolic link.MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link specifies the new symbolic link name.
Target specifies the path (relative or absolute) that the new link refers to.
We will use this command to create a hard link to the file in the “old” folder.
C:\new>mklink /H c:\new\testlink.txt c:\old\test.txt
Hardlink created for c:\new\testlink.txt c:\old\test.txtC:\new>type testlink.txt
“This is so cool!”
We have now created a hard link named testlink.txt in the “new” folder for the file test.txt in the “old” folder, and verified that the content of the hard link is the same as the original file..
At this point we have the file “test.txt” which we originally created in the “old” folder, and a hard link to that file in the “new” folder named “testlink.txt”
Now we simulate reinstalling the OS. We delete the file test.txt from its original location.
C:\new>del c:\old\*.*
c:\old\*.*, Are you sure (Y/N)? yC:\new>dir c:\old
Volume in drive C is Disk 1-1
Volume Serial Number is C6EB-7626Directory of c:\old
21/10/2010 10:32 PM .
21/10/2010 10:32 PM ..
0 File(s) 0 bytes
2 Dir(s) 734,314,283,008 bytes free
We have verified that there are no files left in the “old” folder. Think of this as the removal of the user’s original data folders from the computer being rebuilt.
Now, we return to the new “temporary links” folder.
C:\new>dir c:\new
Volume in drive C is Disk 1-1
Volume Serial Number is C6EB-7626Directory of c:\new
21/10/2010 10:32 PM .
21/10/2010 10:32 PM ..
21/10/2010 10:31 PM 21 testlink.txt
1 File(s) 21 bytes
2 Dir(s) 734,314,266,624 bytes freeC:\new>type testlink.txt
“This is so cool!”
The original file content is still there.
So using USMT and hard link migration, if you need to rebuild a system, the process is now significantly quicker. USMT creates a protected folder for user settings and data to be retained in. Hard links are created in that folder. The system is then reimaged, and the system is wiped (except for the protected folder containing the hard links). After the reinstall, the hard linked data is migrated back to the original location. All this without needing to copy huge amounts of data to and from the client machine for backup. Once the Operating System has been reinstalled, these hard links to the user’s original data are restored to the appropriate location on the user’s newly rebuilt computer, and the temporary hard links folder is removed.
Hopefully that helps demystify the whole process. For more information about Microsoft’s deployment tools and technologies check out their Desktop Deployment Tech Center at http://technet.microsoft.com/en-ca/deployment/default.aspx.