Vous êtes sur la page 1sur 5

Hyper-V generation 2 virtual machines part 4

John Howard MSFT 29 Oct 2013 10:53 AM

20

Part 1: Introduction to generation 2 virtual machines


Part 2: Networking and boot order
Part 3: Storage
Part 4: Keyboard for Windows 8 & Windows Server 2012
Part 5: Kernel debugging
Part 6: Secure Boot
Part 7: FAQ
Part 8: Manually migrating generation 1 virtual machines to generation 2
Part 9: Installing from ISO
Part 10: Utility for converting generation 1 virtual machines to generation 2 ConvertVMGeneration
This part of the series on generation 2 virtual machines in HyperV looks a little more at the keyboard device. This has relevance if
you are running Windows 8 or Windows Server 2012 as a guest operating system, and more specifically WinPE/WinRE from these
operating systems. PE is used, for example, during Windows setup. In part one, I mentioned that we removed the emulated i8042
keyboard device from generation 2 virtual machines. That means the only keyboard device available is the software based
keyboard.
Unfortunately this is also where hindsight is a marvelous asset. In PE & RE environments, the software based keyboard driver is
not present. It was a pure and simple oversight, and Im probably as good a person to blame as anyone. Not literally though
please ;. At the time, noone had thought there might be a need for it to be present in the future. It simply didnt affect any end
user scenarios. Generation 2 virtual machines changed those assumptions.
So lets take the case of when you are installing Windows 8 client into a generation 2 virtual machine booted from an ISO. Its the
retail version which requires a product key. Setup is built on WinPE, and without the software based keyboard driver, you cant
enter the product key. Well I guess you can use the onscreen keyboard. Obviously in the case of unattended installs, you can
get around this. You would hit the same problem doing a network install where the WDS server boot image again based on
WinPE provided to the VM is Windows 8/Windows Server 2012 based. If that is the case, update your boot image to 8.1 and the
problem will go away. Another workaround is to do an initial boot to an ISO containing Windows 8.1 PE from where Windows
8/Windows Server 2012 can be launched.
Fortunately, its relatively easy to solve the above using standard servicing mechanisms, which is what Ill walk through in this part.
Im assuming your client or technician machine is Windows 8.1 with HyperV enabled or you have access to a Windows Server
2012 R2 machine with HyperV enabled. To start with, grab the Windows Assessment and Deployment Kit for Windows 8.1
otherwise known as the ADK from http://www.microsoft.com/enie/download/details.aspx?id=39982. Note I have tried this on
Windows 8 as well, using the Windows 8 version of the ADK, but with prerelease versions of Windows 8.1. It should still work
though.
When installing the ADK, you can use the default options, although if you choose, you only need the Deployment Tools option
for this walkthrough.

Once installed, start an elevated Deployment and Imaging Tools Environment command prompt.
While its installing, grab an ISO of Windows 8 or Windows Server 2012 and copy it locally to the machine where the ADK is
installed. For this walkthrough, Im using an en_us Windows 8 RTM ISO although the language should be irrelevant. Thinking
about it, I should have grabbed the en_gb ISO as I still get frustrated continually seeing Favourites misspelt!
The next think you need is the CAB file which contains the Integration Service .CAB file for Windows 8.1. It is important to use the
.CAB file from the final RTM build of Windows 8.1, not the version from Windows 8.1 preview to avoid driver signing issues and a
conflict with the Secure Boot feature of generation 2 virtual machines. The CAB file can be found under
\Windows\vmguest\support\amd64, named Windows6.2HyperVIntegrationServicesx64.cab. Copy it to a working directory
where the .ISO being modified is located.

Now you need to mount the .ISO as a local drive letter to extract the contents which you are soon going to be modifying. You can
mount it by simply typing the name of the .ISO file at the command prompt, or using Windows File Explorer. Simply copy the
contents, including subdirectories to a temporary directory. In my case, Im using c:\working\extract. After copying, you can
unmount the ISO from explorer by right clicking on the drive and selecting Eject.

Next job is to examine the Windows PE boot WIM image which will be in the sources subdirectory where you just extracted the
.ISO contents. Use dism /getimageinfo to do this. There is a little gotcha here, you need to use DISM from the ADK, not the one
built into Windows to avoid Error: 87 as shown below.

The output shows there are two images in the WIM file, both of which we are going to update. Using another temporary empty
directory, in my case, c:\mount, mount one of the images in the above WIM. Again, using dism, we are going to use the /mount
image parameter. Note the use of the /index: parameter too to match each of the images in the WIM per the above screenshot.

Next we need to add the softwarebased keyboard driver from the CAB file we copied earlier. As the HyperV Integration Services
are catalog signed, it is necessary to apply the complete package of the integration services rather than the single keyboard
driver. This is done using the /addpackage parameter to dism.

And finally, for this image, unmount it, remembering to commit the changes. This is done using dism with the /unmountimage
and /commit parameters.

Heres the raw commands for completeness


dism/getimageinfoboot.wim
dism/mountimage/imagefile:boot.wim/index:1/mountdir:c:\mount
dism/image:c:\mount/addpackage/packagepath:Windows6.2HyperVIntegrationServicesx64.cab
dism/unmountimage/mountdir:c:\mount/commit
Repeat the above three commands but mounting index 2 in the boot.wim file which is the Windows Setup image this time
around.
At this point, you might also optionally want to update the recovery WIM in the media too. This is a tiny bit more complicated due
to the fact that its a WIM inside a WIM. To do this, you need to mount install.wim rather than boot.wim to start with. For example
below, you can see that the media I am using contains Windows 8 and Windows 8 Pro.

The mount of install.wim

Information on winre.wim under \mount\windows\system32\recovery\winre.wim

Mounting the first and only image in WinRE.wim to a second mount temporary directory c:\mount2

Adding the integration services package remember c:\mount2, not c:\mount

Committing the package and unmounting again remember c:\mount2

And now unmounting the Windows 8 image itself from c:\mount committing the contents.

Repeat for each image inside install.wim.


At this point, you are ready to recreate the ISO which can be used for Operating System installation on both generation 1 PCAT
and generation 2 UEFI virtual machines. We use oscdimg.exe from the ADK for this purpose. From the sources directory where
the modified Windows media is extracted, run the following command on one line
Oscdimg
m
o
u2
udfver102
bootdata:2
#p0,e,b<Path>\etfsboot.com
#pEF,e,b<Path>\efisys.bin
<SourceDirectory>
<Target>
These are the relevant parameters:
m

Ignore the maximum size limit of the image

Optimize by removing duplicate files

u2

UDF file system ISO image

udfver102

UDF version will be 1.02

bootdata:2

Specified there will be two boot catalog entries

#p0,e,b<Path>\etfsboot.com

# is the separator between boot entries


p0 sets the platform ID to 0 for the first default boot entry for
the BIOS
e Specifies floppy disk emulation in the El Torito catalog
b<Path>\etfsboot.com Puts the specified file in the boot sectors
of the disk

#pEF,e,b<Path>efisys.bin

# is the separator between first and second entry


pEF sets the platform ID to EF as defined by the UEFI
specification
b<Path>\efisys.bin Puts the specified file Efisys.bin in the boot
sector of the disk. Efisys.bin is the binary floppy disk layout of
the EFI boot code. This disk image contains the files that are
used to start from the EFI firmware in the Efi\boot\x64boot.efi
folder

<Source Directory>

Is the top directory where the modified Windows Media was


extracted to.

<Target>

Is the full path to the .ISO that will be generated.

Note that using just etfsboot.com is not sufficient as this only puts a boot loader suitable for BIOS/PCAT based machines onto the
ISO. More information can be found at http://support.microsoft.com/kb/947024. This KB applies for Windows Server 2008, but
can be used for Windows Server 2012/Windows 8 as well.
Using our previous working directories, heres an example.

Phew! Lets try it out in a new generation 2 virtual machine attaching and installing from the patched ISO.

Of course, you can also use the patched boot.wim file for use on a WDS server. However, I would recommend instead you put the
Windows 8.1 PE and boot.wim on the WDS server instead as these contain the software keyboard driver already.
In the next part, Ill talk about debugging as it relates to generation 2 virtual machines.
Cheers,
John.

Comments
affordable web designers 5 Nov 2013 5:53 AM

Hello..Lovely and fantastic article.. I agree about this article...Thanks to all..


Christophe 25 Nov 2013 3:47 PM

I have a question regarding this problem with keyboard :


Can there be a side effect to Windows 7 when deployed from SCCM 2012 R2 on a Gen 1 VM hosted on Windows 8.1
?
Here's my problem :
I decided to migrate my computer from Windows 8.0 to 8.1 this weekend. In order to do this, I installed Windows
8.1 in a VHDX and decided to boot from VHD and keep my Windows 8.0 on the harddrive. I'm not a big fan of
upgrading an OS.. I prefer reinstalling it.
I have a platform running a number of 2012 R2 servers in VMs in order to test SCCM 2012 R2 in HyperV. I use this
platform to test my Windows 7 deployment scenario. This scenario was working perfectly when HyperV was
running on Windows 8.0
I imported my HyperV VMs in Windows 8.1 HyperV Manager.

Vous aimerez peut-être aussi