The last post I made talked about customizing windows image (.WIM) files, and the post before that talked about creating Virtual hard disk (.VHD) files. So the last step is to look at putting an image onto a VHD and making it bootable
So the steps are
Step 3, applying the image can be done using image X if you have installed the Windows Automated Installation Kit using the command
"<path to AIK>\tools\<architecture>\Imagex.exe" /apply <path to wim> <image number> V:
I mentioned a post by Mike Kolitz, Mike has also got a script on the MSDN code site which goes by the name of WIM2VHD this will create the VHD, apply the WIM file,and patches you provide and copy files into the VHD. Unless you want to customize the registry or turn components on or off this is the ideal tool* but it depends on having the tools from the Automated Installation kit. Mike, to prove what an all-round good chap he is has a PowerShell script on the same site named Install_windowsImage (this script also shows how other languages can be embedded in PowerShell scripts) which removes that dependency so the alternative is to download this and run
<path>\Install-WindowsImage.ps1 -WIM <path to wim> -Apply -Index <image number> -Destination V:
This process takes a few minutes but at the end you have an image which is ready to boot for the first time. Then you’re ready for step 4: making sure the windows boot loader will work.
If the VHD is going to appear as the System disk in a virtual machine the VM will use the boot loader and BCD on the that disk – i.e. we need a boot configuration database inside the VHD. Windows 7 and Server 2008 R2 now have a tool in the \windows\system32 directory named BCDBOOT which recreates the BCD. If you run
<Path\>bcdboot V:\windows V:
It will create a BCD inside the VHD file and when a VM comes to boot from it all will be well.
I’ve discussed adding an entry to the BCD on a machine which is already running Windows Vista/7 /Server 2008 / Server 2008R2 , which needs an entry in the BCD on the physical hard disk which points to the VHD. An alternative way to create the entry uses BCDboot. If you run it with a /M switch it merges the boot information into an existing BCD. So if you are adding a VHD to boot an alternate OS from, then you can use that command. If you’re doing something odd like running windows PE to setup a new machine to boot from a VHD on a newly formatted drive you can use the same bcdboot V:\windows C: to create the store. If you are adding a Windows 7 / Server R2 VHD to a machine with a Vista / Server 2008 installation on it, don’t forget to update the machine to support the new features with bootsect from the windows Install disk.
* I’m assuming you want to know what the steps are and how you could take them manually, rather than just going straight to Wim2VHD.
Is there any reason you wouldn't want to use this as your method for imaging desktops? If the performance is essentially the same now with VHDs....
The performance is one or two perecent lower than native hard disk for FIXED VHDs. Dynamically expanding is a bit slower when the VHD needs to grow. I think if you can put software and OS in the VHD and keep data and page file on the main file system it's a pretty good solution - based on my experience with server 2008 R2.