VHD Native Boot: Part 1 – Windows 7
We will be looking at booting your computer from a VHD. This process will make it so your computer no longer has an installed version of Windows on it. It will only have a VHD, and the machine will boot from this VHD. Microsoft calls this process VHD for Native Boot. In this part, we will go over the basics of Windows 7 Native Boot (BIOS-based) and deploy it using WinPE. In part 2, we will talk about Native Boot for Windows 8.1 and Windows 10 (UEFI-based). In Part 3, we will talk about deploying this VHD from ConfigMgr. Finally, in Part 4 we will talk about differencing disks, where you lay down a base VHD, then all changes are made on another VHD that can either be kept or discarded at reboot.
Requirements
Windows 7 VHD Native Boot only works with a BIOS configuration, not UEFI. The base hardware should be the same between the reference VHD and the deployed VHD, meaning that if you build your reference on Intel-based hardware, the deployed hardware will need to be Intel. It cannot be AMD. You will need a WinPE boot media. If you do not know how to create one, see this TechNet article: https://technet.microsoft.com/en-us/library/dn293200.aspx (just the first two sections – “Install the Windows ADK” and “Install Windows PE to DVD, a CD, or an ISO file”).
Base Image
To create a deployable image, you must have a VHD. There are a two ways to do this. First, you can install Hyper-V and create your base image from there. When you get done, sysprep the image using the “/generalize /oobe /shutdown” parameters and just copy the resulting VHD to computers using the process that I will describe a little later. When you power the machine up the first time, the VHD will run through OOBE and you can configure it. You can also use an answer file, just as you would any other deployment.
Second, you can create your base image on a physical machine or from another virtualization product such as VMware. Here, you can capture the physical machine or VM as a WIM and then apply it to an empty VHD. To that, install Windows on the machine and configure it. Once configured, run your sysprep command with the same parameters mentioned above (“/generalize /oobe /shutdown”). After the machine as shut down, capture a WIM using WinPE. Capturing the WIM with WinPE is outside the scope of this article, but there are many good TechNet blogs out there that describe this process in detail.
After you have your WIM, you can apply it to a VHD. To do that, use a technician computer to create a VHD by opening Disk Management, clicking Action in the toolbar, then “Create VHD”.
Pay attention to the differences between a VHD and a VHDX. From here on out, when I say VHD, you can interchange VHDX. First, if you want to deploy Windows 7, it is not supported on a VHDX. Also, I would recommend keeping the hard disk type set to fixed size. You tend to get better performance, especially in the way that we are using the VHD.
After the VHD is created, you need to mount it to a drive letter and format it with NTFS. Now we can apply the WIM by using this command:
dism.exe /Apply-Image /ImageFile:<path to WIM> /Index:<image index> /ApplyDir:<root of VHD drive>
Example:
dism.exe /apply-image /imagefile:C:\windows7-x64.wim /index:2 /applydir:D:\
The complex part of that command is the index number. It will depend on how you capture the image, but basically, if you leave the system reserve partition in place, the index you will want to use is 2. If you do not, the index will be 1.
After that is done applying, you have your VHD ready. You disconnect the VHD by selecting it in disk manager, going to Action, and selecting “Detach VHD”.
The obvious advantage to using a WIM is that you can take an already-existing based image and apply it to VHDs.
Applying VHD
These steps are the same whether you applied a WIM to a VHD or built your base in Hyper-V. Before completing these steps, you need to copy the VHD to a network share or USB drive.
Remember that this process will erase the existing hard drive.
To begin, boot the machine into WinPE. Type this series of commands to partition the disk appropriately:
diskpart
select disk 0
clean
create partition primary size=300
format quick fs=ntfs
assign letter=s
active
create partition primary
format quick fs=ntfs
assign letter=c
exit
Now that we have our partitions created, we need to copy the VHD to the C drive. To do that, plug in the USB drive or mount the network share that contains your VHD. Run the copy command like this:
copy<path to VHD> C:
Now we need to launch DiskPart again to mount the VHD. Run these commands:
diskpart
select vdisk file=c:\<vhd file>
attach vdisk
list volume
select volume <volume number of VHD>
assign letter=v
exit
Finally, we need to configure the boot environment to boot from the VHD.
cd v:\windows\system32
bcdboot.exe v:\windows /s s:
Now when you restart the machine, it should boot into the VHD and run through the OOBE.
Disclaimer
All content provided on this blog is for information purposes only. Windows Management Experts, Inc makes no representation as to accuracy or completeness of any information on this site. Windows Management Experts, Inc will not be liable for any errors or omission in this information nor for the availability of this information. It is highly recommended that you consult one of our technical consultants, should you need any further assistance.