我尝试使用自动无人值守安装模式在 Proxmox 主机上安装 Windows Server VM。VM 将按预期安装并启动,但网络驱动程序(以及网络配置)不可用。
我已经尝试了几个选项以及来自 Fedora 的演示 Win 2k19 ISO 映像和 Virtio 驱动程序 ISO 映像。
我做什么(使用 Ansible,但这不是这里的问题):
- 挂载 Virtio ISO,将内容与 autounattend.xml 和一些 PowerShell 脚本一起复制到新位置。
- 将该位置打包到一个新的 ISO 文件中
- 创建一个带有两个 CDROM 驱动器的 VM 并安装 Win ISO 和 Drivers-ISO,VM 当然还有硬盘、网络设备等。
- 启动虚拟机
- Windows 安装程序在 e: 上找到 autounattend.xml 并开始自动安装
- autounattend.xml 包含驱动程序 ISO 上的驱动程序的路径,以查找 SCSI 硬盘。这样可行
- 但未加载网络驱动程序,因此我无法通过自动无人值守配置网络。
- 我尝试构建一个 PowerShell 脚本,但还不够,脚本运行,没有错误,但设备管理器显示带有感叹号的 RedHat Virtio 以太网适配器。
- 当我安装后手动运行 virtio-win-gt-x64.msi 时,它说 - 软件已安装,只能删除...
...但是为什么网络驱动程序不起作用?当我重新安装 MSI 软件包时,网络会联机。
<?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>
...
这里是 PowerShell 脚本。
# 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'
虚拟机配置有
- 电脑-i440fx-6.1
- cputype=主机
- 带有 scsi0 的 virtio SCSI 单
- net0 作为 virtio 设备,bridge=vmbr0, firewall=1 - 没有可用的 DHCP
- ide0 与 media=cdrom,local:iso/win2k19.iso
- ide1 与 media=cdrom,local:iso/drivers.iso
我的安装有什么问题,Windows 系统知道 RedHat 以太网适配器,但没有真正使用所需的驱动程序?我还自动安装了 RedHat 证书(以避免在安装过程中出现问题)。但我不能在自动无人值守期间使用它(那时我无法安装证书)。
我也尝试在命令行上直接运行 msiexec。还是一样。它检测到该软件已安装。然后我尝试再次安装该软件,并通过 msiexec 安装在 2-3sek 中运行,然后安装(速度很快)。当我使用 GUI 手动操作时,一切都很好。
msiexec 命令是
msiexec /I e:\virtio-win-gt-x64.msi /qn /passive /log ".." ADDLOCAL=ALL
生成的日志文件大小约为 130k,并且没有错误。我徘徊如果
DIFXAPP: Info: This is a no-op custom action for component CMP_WinServer2019_netkvm.
是正确的。我正在使用Fedora的 0.1.208 版本。