A few weeks back we posted an entry on how to boot from a Windows 7 or Server 2008 R2 VHD. Booting from VHD is new to Windows 7 and Server 2008 R2 but one of the caveats was you needed a “clean” VHD to boot from. There is a very simple way to create this VHD using an open source tool available on the MSDN Code Gallery called WIM2VHD.
WIM2VHD is a command line tool that converts the WIM image into a VHD you can use to boot off. It does have a few requirements…
- The prep machine has to be running Windows 7, Server 2008 R2, either of which could be running in a Hyper-V VM
- A Windows 7 or Server 2008 R2 installation media
- The Windows 7 Automated Install Kit Beta
There are a number of switches you will need to know as well in order to create the VHD file…
- /wim: specifies the path to the WIM file
- /sku: which version (ServerStandard, Ultimate etc…) You can also use the SkuIndex if you retrieved that with the ImageX tool
- /vhd: specifies the path and the name of the VHD to be created
- /size: specifies the size of the VHD in MB
- /disktype: specifies the type of disk, Dynamic or Fixed
There are some additional switches which you can find on the WIM2VHD documentation that allow you to further customize the VHD to be created.
So let’s say we wanted to create a Windows 7 Ultimate VHD on a 40GB fixed disk; we’d use the following command:
cscript wim2vhd.wsf /wim:X:\sources\install.wim /sku:ULTIMATE /vhd:C:\Win7Ultimate.vhd /size:40960 /disktype:Fixed
Or if we wanted to create a Windows Server 2008 R2 Standard VHD on a 40GB dynamically expanding disk we’d use the following command:
cscript wim2vhd.wsf /wim:X:\sources\install.wim /sku:SERVERSTANDARD /vhd:C:\ServerStandardR2.vhd /size:40960 /disktype:Dynamic