In many cases you only need to create VHD files for a virtual PC, but in some cases you may need to install a 64 bit OS. I needed to do exactly that when I decided it would be the quickest and cleanest way to do SharePoint 2010 development. Now one thing you should be aware of is that if you take this approach you will need a significant amount of space for each VHD file, unless it is a differential file. For a Windows 7 or Server 2008 R2 Install, I will typically use a 100GB VHD file, so make sure you have that much space available before we begin.
Before we begin
All tasks require Admin Access to your box and there are a few items you will need before you begin the build of your VHD, first you will need the Install.wim file found on your install DVD in the Sources directory. Additionally, you should download copies of all your systems drivers and store them in a single directory for access later. Lastly you will need to download and install the Windows AIK for Windows 7 (http://www.microsoft.com/downloads/en/details.aspx?familyid=696DD665-9F76-4177-A811-39C26D3B3B34&displaylang=en)
Create the VHD
- Click Start
- Right Click on Computer and Click Manage
- Under Storage, Click Disk Management
- Once the Disk Configuration Window is refreshed, under Action click More Actions > Create VHD
- Specify the location and Name of the VHD file and set the size, then Click OK.
- Once the setup completes you will find the Image in the list of Drives as a teal coloured drive icon.
Initialize and Partition the VHD
- Right Click on the Grey area that contains the icon and choose Initialize Disk.
- Choose MBR or GPT (GPT is newer and supports partitions larger than 2TB) and click OK
- Right Click on the White area of the drive area with a black title that show a status of Unallocated, choose New Simple Volume…
- Click Next >
- Click Next >
- Choose Assign the following drive letter (remember the letter chosen) and click Next >
- Give the Drive a Volume label that makes it easy to identify, make sure quick format is chosen and click Next >
- Click Finish
- The bar on the top will turn blue and the drive will have the letter and label you gave it. If autoplay is turned on an autoplay popup will appear, close it.
- Right Click on the white area and choose Mark Partition as Active
Install the OS and Add the Drivers
- Click Start > All Programs > Microsoft Windows AIK and Right Click on Deployment Tools Command Prompt and choose Run as Administrator
- Type: imagex /info {Install.wim Path}\install.wim eg: imagex /info c:\VHD\install.wim
- In the result find the Index of the install you want to start
- Type: imagex /apply {Install.wim Path}\install.wim /check {Index Number} {VHD Drive} eg: imagex /apply c:\VHD\install.wim /check 1 g:\
- Wait for the install to complete
- Type: dism /image:{VHD Drive} /add-driver /driver:{Path to drivers} /recurse eg: dism /image:g:\ /add-driver /driver:c:\drivers /recurse
Note: You should only navigate to the top level of the drivers folder, the recurse switch tells it to search all subfolders for drivers and install them.
Change the Boot Menu
- Type: bcdedit /copy {current} /d "{Label}" eg: bcdedit /copy {current} /d "Windows 7 - VHD"
- Type: bcdedit
- Copy the CLSID property called Identifier using Mark for the entry that has the description that matches the label you entered above
- Type: bcdedit /set {CLSID} device vhd=[{Drive Letter}]{VHD Path}\{VHD Filename} eg: bcdedit /set {b751de95-e30f-11df-b2f6-85541b19d1f4} device vhd=[C:]\VHD\Windows7.vhd
- Type: bcdedit /set {CLSID} osdevice vhd=[{Drive Letter}]{VHD Path}\{VHD Filename}
- Type: bcdedit /set {CLSID} detecthal on
- Now you can reboot into the new image
Using Differential Images to keep your OS Image Pristine
If you install all the base software and perform updates to make the image current, you can then create a Differential Image, which will allow you to make changes without affecting the base image, eg. Test new software or perform development.
- Click Start > All Programs > Microsoft Windows AIK and Right Click on Deployment Tools Command Prompt and choose Run as Administrator
- Type: diskpart
- Type: create vdisk file={Drive Letter}\{VHD DIF FileName} parent={Drive Letter}\{VHD FileName} eg: create vdisk file=c:\VHD\VS2010.vhd parent=c:\VHD\windows7.vhd
- Change the boot menu to point to the new image for device and osdevice
No comments:
Post a Comment