Difference between revisions of "Windows guests - build ISOs including VirtIO drivers"

From Proxmox VE
Jump to navigation Jump to search
 
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
=Build ISOs including VirtIO drivers=
+
Using [[Paravirtualized Block Drivers for Windows]] can dramatically improve Windows guest performance but installing them can be a bit of a fuss. This Tutorial shows you how you can inject all VirtIO drivers into all of your Windows install ISOs in one step using Windows® Automated Installation Kit and some batch files. This makes it really easy to deploy Windows with the most efficient hardware/driver configuration.
  
Using [[Paravirtualized Block Drivers for Windows]] can dramatically improve Windows guest performance but installing them can be a bit of a fuss.
+
== Prep Machine ==
 
 
==Prep Machine==
 
  
 
* Launch a fast Windows 7 box and create a folder c:\tmp
 
* Launch a fast Windows 7 box and create a folder c:\tmp
 
* install AIK for Windows 7 (http://www.microsoft.com/en-us/download/details.aspx?id=5753)
 
* install AIK for Windows 7 (http://www.microsoft.com/en-us/download/details.aspx?id=5753)
 
* install an ISO editor such as UltraIso
 
* install an ISO editor such as UltraIso
* unpack [[File:Inject-virtio-drivers.zip|Inject-virtio-drivers.zip]] to c:\tmp
+
* unpack [[File:Inject-virtio-drivers.zip]] batch files to c:\tmp
  
  
== Prep and extract isos==
+
== Prep and extract isos ==
  
 
* copy all your Windows ISOs to folders c:\tmp\win7, c:\tmp\win2008, c:\tmp\win8, c:\tmp\win2012, etc
 
* copy all your Windows ISOs to folders c:\tmp\win7, c:\tmp\win2008, c:\tmp\win8, c:\tmp\win2012, etc
* extract sources\boot.wim and sources\install.wim from each iso and put them in the same folder as the iso
+
* extract sources\boot.wim and sources\install.wim from each iso (e.g. by using UltraISO) and put them in the same folder as the iso
* get the latest [http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/ virtio-win-x.x-xx.iso] and extract the drivers into the VirtIO folder for each OS (e.g. WIN8\AMD64\*.* from the iso goes into c:\tmp\win8\VirtIO\ and into c:\tmp\win2012\VirtIO\)
+
* get the latest [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/ virtio-win-x.x-xx.iso] and extract the drivers into the VirtIO folder for each OS (e.g. WIN8\AMD64\*.* from the iso goes into c:\tmp\win8\VirtIO\ and into c:\tmp\win2012\VirtIO\)
  
  
==use AIK==
+
== Use AIK ==
  
 
* Start All Programs -> Microsoft Windows AIK -> Deployment Tools Command Prompt (Run as Administrator)
 
* Start All Programs -> Microsoft Windows AIK -> Deployment Tools Command Prompt (Run as Administrator)
* check how many indexes your install.wim has (e.g. dism /get-wiminfo /wimfile:c:\tmp\win2008\install.wim). Windows 2008 has up to 8 indexes
+
* check how many indices your install.wim has (e.g. dism /get-wiminfo /wimfile:c:\tmp\win2008\install.wim). Windows 2008 has up to 8 indices
 +
 
 +
<pre>
 +
dism /get-wiminfo /wimfile:c:\tmp\win2008\install.wim
 +
.
 +
.
 +
Index : 7
 +
Name : Windows Server 2008 R2 SERVERWEB
 +
Description : Windows Server 2008 R2 SERVERWEB
 +
Size : 10,538,107,020 bytes
 +
 
 +
Index : 8
 +
Name : Windows Server 2008 R2 SERVERWEBCORE
 +
Description : Windows Server 2008 R2 SERVERWEBCORE
 +
Size : 3,580,635,107 bytes
 +
 
 +
The operation completed successfully.
 +
</pre>
 +
 
 
* Set the variable IDX in each winxxxx-inject.bat to the number of indices you found in each install.wim (e.g. IDX=8)
 
* Set the variable IDX in each winxxxx-inject.bat to the number of indices you found in each install.wim (e.g. IDX=8)
 
* For each OS there is a SetupComplete.cmd. This script is always executed by the Windows installation as a final step. Make sure it contains the ballon service installer. You may add other commands to it.
 
* For each OS there is a SetupComplete.cmd. This script is always executed by the Windows installation as a final step. Make sure it contains the ballon service installer. You may add other commands to it.
  
==inject drivers and write wim files back to isos==
+
== Inject drivers and write wim files back to isos ==
* launch multiple winxxxx-inject.bat sequentially and uninterrupted, e.g.: winpe-inject.bat && win7-inject.bat && win2008-inject.bat && win8-inject.bat && win2012-inject.bat
+
* launch multiple winxxxx-inject.bat sequentially and uninterrupted, e.g.: winpe-inject.bat && win7-inject.bat etc.
 +
 
 +
winpe-inject.bat && win7-inject.bat && win2008-inject.bat && win8-inject.bat && win2012-inject.bat
 +
 
 
* alternatively you can run multiple batch commands in parallel by launching multiple instances of "Deployment Tools Command Prompt" as Administrator
 
* alternatively you can run multiple batch commands in parallel by launching multiple instances of "Deployment Tools Command Prompt" as Administrator
 
* for each iso use UltraISO to copy boot.wim and install.wim back to the sources folder of the ISO file
 
* for each iso use UltraISO to copy boot.wim and install.wim back to the sources folder of the ISO file
  
=== example batch file win2012-inject.bat ===
+
=== Example batch file win2012-inject.bat ===
<PRE>
+
<pre>
 
@echo off
 
@echo off
  
Line 60: Line 79:
  
 
:eof
 
:eof
</PRE>
+
</pre>
 
 
 
 
=Additional Options=
 
 
 
==change the Proxmox UI default settings to VirtIO==
 
 
 
Now that you have changed all your ISO files to include Paravirtualized drivers you no longer need IDE drives or a E1000 network adapter. Wouldn't it be best to change the defaults to the settings that use our resources most efficiently. Please follow these instructions to patch the PVE UI. [[Defaults - change PVE UI defaults to VirtIO]]
 
 
 
==virtio drivers==
 
Use virtio dirvers for best performance. More info:
 
[[Paravirtualized Block Drivers for Windows]]
 
  
latest iso with virtio drivers :
+
== Additional Info ==
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/
 
  
 +
Now that you have changed all your ISO files to include Paravirtualized drivers you no longer need IDE drives or a E1000 network adapter.
 +
Always select VirtIO for the Disk Controller and VirtIO when selecting a network card in the Creation Wizard.
  
[[Windows 2012 guest best practices]]
+
== See also ==
  
[[Windows 2008 guest best practices]]
+
* [[Windows 2012 guest best practices]]
 +
* [[Windows 2008 guest best practices]]
  
 
[[Category: HOWTO]]
 
[[Category: HOWTO]]

Latest revision as of 14:25, 3 October 2016

Using Paravirtualized Block Drivers for Windows can dramatically improve Windows guest performance but installing them can be a bit of a fuss. This Tutorial shows you how you can inject all VirtIO drivers into all of your Windows install ISOs in one step using Windows® Automated Installation Kit and some batch files. This makes it really easy to deploy Windows with the most efficient hardware/driver configuration.

Prep Machine


Prep and extract isos

  • copy all your Windows ISOs to folders c:\tmp\win7, c:\tmp\win2008, c:\tmp\win8, c:\tmp\win2012, etc
  • extract sources\boot.wim and sources\install.wim from each iso (e.g. by using UltraISO) and put them in the same folder as the iso
  • get the latest virtio-win-x.x-xx.iso and extract the drivers into the VirtIO folder for each OS (e.g. WIN8\AMD64\*.* from the iso goes into c:\tmp\win8\VirtIO\ and into c:\tmp\win2012\VirtIO\)


Use AIK

  • Start All Programs -> Microsoft Windows AIK -> Deployment Tools Command Prompt (Run as Administrator)
  • check how many indices your install.wim has (e.g. dism /get-wiminfo /wimfile:c:\tmp\win2008\install.wim). Windows 2008 has up to 8 indices
 dism /get-wiminfo /wimfile:c:\tmp\win2008\install.wim
 .
 .
 Index : 7
 Name : Windows Server 2008 R2 SERVERWEB
 Description : Windows Server 2008 R2 SERVERWEB
 Size : 10,538,107,020 bytes

 Index : 8
 Name : Windows Server 2008 R2 SERVERWEBCORE
 Description : Windows Server 2008 R2 SERVERWEBCORE
 Size : 3,580,635,107 bytes

 The operation completed successfully.
  • Set the variable IDX in each winxxxx-inject.bat to the number of indices you found in each install.wim (e.g. IDX=8)
  • For each OS there is a SetupComplete.cmd. This script is always executed by the Windows installation as a final step. Make sure it contains the ballon service installer. You may add other commands to it.

Inject drivers and write wim files back to isos

  • launch multiple winxxxx-inject.bat sequentially and uninterrupted, e.g.: winpe-inject.bat && win7-inject.bat etc.
winpe-inject.bat && win7-inject.bat && win2008-inject.bat && win8-inject.bat && win2012-inject.bat
  • alternatively you can run multiple batch commands in parallel by launching multiple instances of "Deployment Tools Command Prompt" as Administrator
  • for each iso use UltraISO to copy boot.wim and install.wim back to the sources folder of the ISO file

Example batch file win2012-inject.bat

@echo off

set MyOS=win2012
set IDX=4

if not exist c:\tmp\%MyOS%\virtio\blnsvr.exe (echo Please copy the VirtIO drivers to c:\tmp\%MyOS%\VirtIO\ first && goto :eof)

rem **********(1,1,2) means 2 loops *************************
FOR /L %%i IN (1,1,2) DO (
  ECHO Prepping %MyOS% boot.wim - Index %%i
  if not exist c:\tmp\%MyOS%\bootwim\%%i mkdir c:\tmp\%MyOS%\bootwim\%%i
  imagex /mountrw c:\tmp\%MyOS%\boot.wim %%i c:\tmp\%MyOS%\bootwim\%%i
  dism /image:c:\tmp\%MyOS%\bootwim\%%i /add-driver /driver:c:\tmp\%MyOS%\virtio /Recurse /ForceUnsigned
  imagex /unmount /commit c:\tmp\%MyOS%\bootwim\%%i
)


FOR /L %%i IN (1,1,%IDX%) DO (
  ECHO Prepping %MyOS% install.wim - Index %%i
  if not exist c:\tmp\%MyOS%\installwim\%%i mkdir c:\tmp\%MyOS%\installwim\%%i
  imagex /mountrw c:\tmp\%MyOS%\install.wim %%i c:\tmp\%MyOS%\installwim\%%i
  dism /image:c:\tmp\%MyOS%\installwim\%%i /add-driver /driver:c:\tmp\%MyOS%\virtio /Recurse /ForceUnsigned
  xcopy /Y c:\tmp\%MyOS%\VirtIO "C:\tmp\%MyOS%\installwim\%%i\Program Files\VirtIO\"
  xcopy /Y c:\tmp\%MyOS%\SetupComplete.cmd "C:\tmp\%MyOS%\installwim\%%i\Windows\Setup\Scripts\"
  imagex /unmount /commit c:\tmp\%MyOS%\installwim\%%i
)

:eof

Additional Info

Now that you have changed all your ISO files to include Paravirtualized drivers you no longer need IDE drives or a E1000 network adapter. Always select VirtIO for the Disk Controller and VirtIO when selecting a network card in the Creation Wizard.

See also