Unattended installation of Windows Server 2012 on KVM

kvm-virtualizationunattendedwindows-server-2012-r2

I am trying to perform an unattended install of Windows Server 2012
into a KVM virtual machine, using virt-install. The installer is
complaining, "Windows cannot read the <ProductKey> setting from the
unattend answer file", and I've been unable to figure out how to
proceed past this point.

I am starting with the following autounattend.xml file:

<unattend xmlns="urn:schemas-microsoft-com:unattend"
xmlns:ms="urn:schemas-microsoft-com:asm.v3"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
  <settings pass="windowsPE">
    <component name="Microsoft-Windows-Setup"
    publicKeyToken="31bf3856ad364e35" language="neutral"
    versionScope="nonSxS" processorArchitecture="x86">
      <UserData>
        <AcceptEula>true</AcceptEula>
        <ProductKey>
          <Key>XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</Key>
          <WillShowUI>OnError</WillShowUI>
        </ProductKey>
      </UserData>
      <ImageInstall>
        <OSImage>
          <WillShowUI>Never</WillShowUI>
          <InstallTo>
            <DiskID>0</DiskID>
            <PartitionID>1</PartitionID>
          </InstallTo>
          <InstallFrom>
            <MetaData>
              <Key>/IMAGE/Name</Key>
              <Value>Windows Longhorn SERVERSTANDARDCORE</Value>
            </MetaData>
          </InstallFrom>
        </OSImage>
      </ImageInstall>
    </component>
  </settings>
</unattend>

I am baking this into an ISO image using mkisofs:

$ ls config/
autounattend.xml
$ mkisofs -o config.iso -J -r config

And then I'm starting the install like this:

virt-install -n ws2012 -r 2048 -w network=default,model=virtio \
  --disk path=ws2012.qcow2,device=disk,bus=virtio \
  --cdrom en_windows_server_2012_r2_with_update_x64_dvd_4065220.iso \
  --disk path=virtio-win-0.1-81.iso,device=cdrom \
  --disk path=config.iso,device=cdrom \
  --os-type windows --os-variant win2k8

Looking at x:\windows\panther\setupact.log, I can see that the
installer does find the unattend file:

2014-11-14 12:29:43, Info  [0x060114] IBS
Callback_Productkey_Validate_Unattend:User specified an unattend
xml file

The specified product key is valid (I can copy and paste it from this
file into the product key dialog and the installation will proceed
correctly).

Do you know how to make this install work?

Best Answer

In this case the answer was simple. I had:

<component name="Microsoft-Windows-Setup"
publicKeyToken="31bf3856ad364e35" language="neutral"
versionScope="nonSxS" processorArchitecture="x86">

When I needed:

<component name="Microsoft-Windows-Setup"
publicKeyToken="31bf3856ad364e35" language="neutral"
versionScope="nonSxS" processorArchitecture="amd64">

That is, I had the wrong processorArchitecture in my XML (which I totally should have spotted earlier).

I know have a working, fully-automated process that results in Windows image suitable for deployment in OpenStack. The scripts and config I'm using are available on github.