TRW
TRW

Reputation: 1004

Unattend Installation with virtio drivers doesn't activate network drivers

I try to install a Windows Server VM on a Proxmox host with autounattended installation mode. The VM will be installed and starts as expected, but the network drivers (and so the network configuration) are not available.

I've tried several options together with demo Win 2k19 ISO image and the Virtio drivers ISO image from Fedora.

What I do (with Ansible, but that isn't the issue here):

... but why is the network driver not working? When I reinstall the MSI package the network comes online.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
  <settings pass="windowsPE">
    <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="{{ bootstrap_host_type }}" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <SetupUILanguage>
        <UILanguage>de-DE</UILanguage>
      </SetupUILanguage>
      <InputLocale>de-DE</InputLocale>
      <SystemLocale>de-DE</SystemLocale>
      <UILanguage>de-DE</UILanguage>
      <UILanguageFallback>en-US</UILanguageFallback>
      <UserLocale>de-DE</UserLocale>
    </component>

    <component name="Microsoft-Windows-PnpCustomizationsWinPE" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="{{ bootstrap_host_type }}" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <DriverPaths>

        <PathAndCredentials wcm:action="add" wcm:keyValue="1">
          <Path>E:\{{ bootstrap_host_type }}\{{ bootstrap_os_version }}</Path>
        </PathAndCredentials>

        <PathAndCredentials wcm:action="add" wcm:keyValue="2">
          <Path>E:\viostor\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>

        <PathAndCredentials wcm:action="add" wcm:keyValue="3">
          <Path>E:\NetKVM\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="4">
          <Path>E:\Balloon\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="5">
          <Path>E:\pvpanic\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="6">
          <Path>E:\qemupciserial\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="7">
          <Path>E:\qxldod\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="8">
          <Path>E:\vioinput\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="9">
          <Path>E:\viorng\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="10">
          <Path>E:\vioscsi\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="11">
          <Path>E:\vioserial\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>
  
        <PathAndCredentials wcm:action="add" wcm:keyValue="12">
          <Path>E:\vioserial\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}</Path>
        </PathAndCredentials>

      </DriverPaths>
    </component>

...

  <settings pass="specialize">

    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="{{ bootstrap_host_type }}" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <OEMInformation>
        <HelpCustomized>false</HelpCustomized>
      </OEMInformation>
      <ComputerName>*</ComputerName>
      <TimeZone>{{ vm_time_zone }}</TimeZone>
      <RegisteredOwner/>
    </component>

    <component name="Microsoft-Windows-TCPIP" processorArchitecture="{{ bootstrap_host_type }}" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Interfaces>
        <Interface wcm:action="add">
          <Ipv6Settings>
            <DhcpEnabled>false</DhcpEnabled> 
            <Metric>30</Metric> 
            <RouterDiscoveryEnabled>true</RouterDiscoveryEnabled> 
          </Ipv6Settings>
          <Identifier>Ethernet 1</Identifier>
          <UnicastIpAddresses>
            <IpAddress wcm:action="add" wcm:keyValue="1">{{ network.wan.ipv6.address }}/{{ network.wan.ipv6.prefix }}</IpAddress>
          </UnicastIpAddresses>
          <Routes>
            <Route wcm:action="add">
              <Identifier>1</Identifier> 
              <Metric>10</Metric> 
              <NextHopAddress>{{ network.wan.ipv6.gateway }}</NextHopAddress> 
              <Prefix>0</Prefix> 
            </Route>
          </Routes>
        </Interface>
      </Interfaces>
    </component>

...

  <settings pass="oobeSystem">
    <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="{{ bootstrap_host_type }}" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <AutoLogon>
        <Username>administrator</Username>
        <Password>
          <Value>{{ vm_admin_pass }}</Value>
          <PlainText>true</PlainText>
        </Password>
        <Enabled>true</Enabled>
        <LogonCount>3</LogonCount>
      </AutoLogon>

      <FirstLogonCommands>

        <SynchronousCommand wcm:action="add">
          <CommandLine>%SystemRoot%\System32\reg.exe ADD HKLM\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff /f</CommandLine>
          <Order>1</Order>
          <Description>Disable Network Discovery Prompt</Description>
        </SynchronousCommand>

        <SynchronousCommand wcm:action="add">
          <CommandLine>powershell -File e:\scripts\configure.ps1</CommandLine>
          <Description>Install and configure common tasks</Description>
          <Order>2</Order>
        </SynchronousCommand>

...

and here the PowerShell script.

# Create Workdir
$BasePath = "C:\Windows\Temp\Install"
New-item $BasePath -itemtype directory

# Add RedHat to Trusted Publisher
$CertName = "redhat.cer"
$CertFile = Join-Path $BasePath -ChildPath $CertName

$Cert = (Get-AuthenticodeSignature "e:\pvpanic\{{ bootstrap_os_version }}\{{ bootstrap_host_type }}\pvpanic.sys").SignerCertificate
$ExportType = [System.Security.Cryptography.X509Certificates.X509ContentType]::Cert

[System.IO.File]::WriteAllBytes($CertFile, $Cert.Export($ExportType))
Import-Certificate -FilePath $CertFile -CertStoreLocation Cert:\LocalMachine\TrustedPublisher

Start-Sleep -s 5

# install Virtio Drivers
Start-Process msiexec -Wait -ArgumentList '/i e:\virtio-win-gt-x64.msi /log "C:\Windows\Temp\Install\qemu-drivers.log" /qn /passive /norestart ADDLOCAL=ALL'

The VM is configured with

What is wrong with my installation, that the Windows system knows the RedHat ethernet adapter but isn't really using the desired drivers? I've also installed automatically the RedHat certificate (to avoid questions during installation). But I cannot use that during autounattend (at that moment I cannot install certificates).

Also I tried to run the msiexec direct on command line. Still the same. It detects, that the software is already installed. Then I try to install the software again and via msiexec that installation runs in 2-3sek and then it is installed (which is to fast). When I do it manually with the GUI, everything is fine.

The msiexec command is

msiexec /I e:\virtio-win-gt-x64.msi /qn /passive /log ".." ADDLOCAL=ALL

The generated logfiles is about 130k in size and contains no errors. I wander if

DIFXAPP: Info: This is a no-op custom action for component CMP_WinServer2019_netkvm.

is correct. I'm using version 0.1.208 from Fedora.

Upvotes: 1

Views: 2779

Answers (2)

TRW
TRW

Reputation: 1004

As response to my own question. Using the MSI packages seems to have a strange problem with the arguments. It looks like the msiexec installation is ignoring the ADDLOCAL attribute and/or installs "something", but not the correct drivers. Also it is strange, that the concrete driver installation does not have any effect. It seems to me, there is something missing in automatic installation process.

I cannot say why, but using the virtio-guest-tools.exe seems to work.... more or less. I need to install, uninstall and install the software again - then the network device comes online and I can configure it via New-NetIPAddress.

Start-Process -Wait -NoNewWindow -FilePath 'e:\virtio-win-guest-tools.exe' -ArgumentList '/s /qn'
Start-Process -Wait -NoNewWindow -FilePath 'e:\virtio-win-guest-tools.exe' -ArgumentList '/s /qn /uninstall'
Start-Process -Wait -NoNewWindow -FilePath 'e:\virtio-win-guest-tools.exe' -ArgumentList '/s /qn'

So - this works for me. But this is ugly, unnormal and should never be the correct answer.

Upvotes: 2

Steve Brown
Steve Brown

Reputation: 77

Have you tried just using pnputil to install the drivers and bypassing the msi installer entirely?

In my environment (Proxmox VE 6.2-6 running Server 2019 Core VM's) I mount the CD and then run:

Get-ChildItem E:\ -Recurse -Filter "*.inf" | ForEach-Object { pnputil.exe /add-driver $_.FullName /install }

Which results in all the applicable drivers being installed and selected properly.

If you need the QEMU agent to be installed to support ACPI commands and the like then you can add:

$Installer = "qemu-ga-x86_64.msi"
if ([Environment]::Is64BitOperatingSystem -eq $false)
{ 
    $Installer = "qemu-ga-i386.msi"
}
Start-Process msiexec -ArgumentList "/I e:\GUEST-AGENT\$Installer /qn /norestart" -Wait -NoNewWindow

Upvotes: 2

Related Questions