MDT 2012 includes a task sequence for deploying an operating system into a VHD, setting up the computer for booting from that VHD. See my previous blog posting about Deploy to VHD for more details on that. As I mentioned in that blog, setting up a differencing disk to be created during the “Deploy to VHD” task sequence doesn’t make sense, as the parent VHD would be empty. But it would be useful to be able to do it later, so that you have the already installed and configured OS in the main VHD, and then one or more differencing disks set up with that VHD as the parent.
So how do you actually do that? The basic steps would be:
To help with that process, I created a new script called Diff.wsf, attached below, that will perform all of those steps. Set up a new custom task sequence in your MDT deployment share that has a single step in it that runs the script like so:
Then reboot into your MDT Lite Touch boot image (either from media or from PXE) and run this task sequence. The command line parameters above tell it what to do:
The task sequence completes while in Windows PE, and as soon as you click finish on the summary wizard page, the computer will reboot into the new differencing disk, causing all changes to be written into the diff file while the parent VHD remains unchanged (and effectively read-only).
After that initial differencing disk has been created, the locally-staged script can be run directly without even using a task sequence. Assuming that the drive letter assigned to the physical disk containing the parent VHD (and the differencing disks) is D:, then the script will be located at D:\VHD\Scripts\Diff.wsf. When you run it from there (initiated from within the currently-running OS), you can specify any of the parameters described above, or you can leave off the parameters and the script will prompt.
Note that the script can’t actually delete the differencing disk that is presently in use because, well, it’s currently in use. But it can remove the BCD entry for it, and after a reboot it can then be deleted. So the script will also take care of cleaning up any “orphaned” differencing disks it finds laying around.
A few final comments on scenarios for running Diff.wsf from within the currently-running OS:
I did something similar to this by building a boot WIM with all the scripting needed and putting that onto the D:\VHD folder during deployment and also adding an entry in the BCD so I could boot into PE whenever I want. At the end of my deployment TS the machine reboots into PE, creates a DIFF VHD using Diskpart, and then modifies the BCD to boot from the new DIFF VHD. The result is that from any time from then on if you want to get the computer back to the way it was when it was first deployed, you just run another script to boot back into PE, delete the DIFF VHD, and modify the BCD accordingly. This is a tremendous timesaver for testing when you must use a physical machine. I've taken it a step further with another script to take a DIFF of the first DIFF and so I can essentially take snapshots and revert as well as go back to the "factory" configuration.
I think I read about deploying VHD Win7 images on your blog, and this method offers all sorts of great opportunities. With some work you can even get the VHD into Hyper-V, but that is another subject.
I would like to know, if you have the info where can I modify the VHD settings for this tasks like Description, because when I boot I have 2 Win7 entries and I would liek to know where on MDT scripts or variables I could modify the VHD entry on bcdedit part. thanks