[TUTORIAL] Build Windows Server ISO with Buildin VirtioDrivers

Mar 7, 2022
20
2
8
40
Since the Wiki Article on building Windows Guest ISO#s with buildin Virtio-Drivers seems to be out of date a bit, here is a Guide on "How to build Win2k19 and Win2K22 Server ISO's".

Disclaimer: This is based on the following guidance:
https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000bt28CAA
https://pve.proxmox.com/wiki/Windows_guests_-_build_ISOs_including_VirtIO_drivers

What you'll need:

Assumptions
  • Windows Server ISO is mounted as Drive F:
  • VirtioISO is mounted as Drive G:


Execution:

  1. Start Powershell with Administrative privilages
  2. Copy and Paste the Contents of one of the following scripts into said shell
  3. Find your ISO at C:\VirtIO\
  4. (optional) - if you will be building another ISO, go ahead and delete the contents of C:\VirtIO\windows_temp



Bash:
#Server 2K22 Standard GUI with Virtio drivers
#Server 2K19 Standard GUI with Virtio drivers

# This is based on the following guidance:
# https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000bt28CAA
# https://pve.proxmox.com/wiki/Windows_guests_-_build_ISOs_including_VirtIO_drivers




#What you'll need:

#    *PowerShell.
#    *Windows ADK (Deployment and Imaging Tools Environment: https://go.microsoft.com/fwlink/?linkid=2120254
#    *Windows 2k19 or 2K22 installation ISO.
#     *Virtio Driver Package ISO: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/
#    *Administrative privileges on your Windows admin workstation.

# Steps 1: Mount the following ISO's and note the Drive-letters (you'll need to addapt the script below based on your ISO-Mounts):
# *Windows 2k19  (in this Guide it is F:)
# *Virtio drivers (in this Guide it is G:)


#Step 2.1: Open Powershell as admin and create temp folders on your C: drive :

mkdir C:\VirtIO\windows_temp,C:\VirtIO\mountBoot,C:\VirtIO\mountInstall

#Step 2.2: Copy the mounted Windows ISO contents to the windows_temp folder:

Copy-Item F:\* C:\VirtIO\windows_temp\ -Recurse

#Step 2.3: Change the image "C:\VirtIO\windows_temp\sources\"  files boot.wim and install.wim file permissions to read/write in the windows_temp directory

attrib -r C:\VirtIO\windows_temp\sources\*.wim /s

#Step 2.4: Verify the Image export:

Get-windowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim


#Step 3.1: Inject drivers
#Review and choose an index that belongs to "Microsoft Windows Setup" in boot.wim:

Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\boot.wim

# Step 3.2: Select Standard GUI Variant:
#Mount the boot.wim file for driver injection. Note the use of "-Index 2":

Mount-windowsImage -Path C:\VirtIO\mountBoot\ -ImagePath C:\VirtIO\windows_temp\sources\boot.wim -Index 2

# Step 3.3: Inject the Virtio drivers into the boot.vim


Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\amd64\2k19\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\Balloon\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\fwcfg\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\NetKVM\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\qemupciserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\sriov\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viofs\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viogpudo\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioinput\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viorng\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioscsi\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viostor\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k19\amd64 -Recurse


#Step 3.4:Use the following command to verify that drivers were injected.
Get-WindowsDriver -Path C:\VirtIO\mountBoot\


# Step 3.5: Save and unmount the boot.wim image:

Dismount-windowsImage -Path C:\VirtIO\mountBoot\ -Save

#4.0: Perform the following steps to inject drivers into install.wim:
Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim



# 4.1.0 Mount the Windows Image Index 4 (Datacenter - GUI) :
Mount-WindowsImage -Path C:\VirtIO\mountInstall\ -ImagePath C:\VirtIO\windows_temp\sources\install.wim -Index 4

# 4.1.1 Inject the  VirtIO drivers into the install.wim image:


Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\amd64\2k19\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\Balloon\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\fwcfg\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\NetKVM\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\qemupciserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\sriov\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viofs\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viogpudo\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioinput\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viorng\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioscsi\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viostor\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k19\amd64 -Recurse

#4.1.2 Save and unmount the install.wim image
Dismount-WindowsImage -Path C:\VirtIO\mountInstall\ -Save


# 5.1 Create ISO using OSCDIMG

cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg"

.\oscdimg -lWINSERV2K19_Standard_GUI_virtio -m -u2 -bC:\VirtIO\windows_temp\boot\etfsboot.com C:\VirtIO\windows_temp\ C:\VirtIO\WINSERV2K19_Datacenter_GUI_virtio.iso


Bash:
#Server 2K19 Standard GUI with Virtio drivers
#Server 2K19 Standard GUI with Virtio drivers

# This is based on the following guidance:
# https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000bt28CAA
# https://pve.proxmox.com/wiki/Windows_guests_-_build_ISOs_including_VirtIO_drivers




#What you'll need:

#    *PowerShell.
#    *Windows ADK (Deployment and Imaging Tools Environment: https://go.microsoft.com/fwlink/?linkid=2120254
#    *Windows 2K19 installation ISO.
#     *Virtio Driver Package ISO: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/
#    *Administrative privileges on your Windows admin workstation.

# Steps 1: Mount the following ISO's and note the Drive-letters (you'll need to addapt the script below):
# *Windows 2k19  (in this Guide it is F:)
# *Virtio drivers (in this Guide it is G:)


#Step 2.1: Open Powershell as admin and create temp folders on your C: drive :

mkdir C:\VirtIO\windows_temp,C:\VirtIO\mountBoot,C:\VirtIO\mountInstall

#Step 2.2: Copy the mounted Windows ISO contents to the windows_temp folder:

Copy-Item F:\* C:\VirtIO\windows_temp\ -Recurse

#Step 2.3: Change the image "C:\VirtIO\windows_temp\sources\"  files boot.wim and install.wim file permissions to read/write in the windows_temp directory

attrib -r C:\VirtIO\windows_temp\sources\*.wim /s

#Step 2.4: Verify the Image export:

Get-windowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim


#Step 3.1: Inject drivers

#Review and choose an index that belongs to "Microsoft Windows Setup" in boot.wim:

Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\boot.wim

# Step 3.2: Mount the boot.wim file for driver injection. Note the use of "-Index 2":
Mount-windowsImage -Path C:\VirtIO\mountBoot\ -ImagePath C:\VirtIO\windows_temp\sources\boot.wim -Index 2

# Step 3.3: Inject the Virtio drivers into the boot.vim


Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\amd64\2k19\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\Balloon\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\fwcfg\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\NetKVM\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\qemupciserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\sriov\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viofs\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viogpudo\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioinput\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viorng\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioscsi\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viostor\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k19\amd64 -Recurse


#Step 3.4: Use "Get-WindowsDriver -Path C:\VirtIO\mountBoot\" command to verify that drivers were injected.
Get-WindowsDriver -Path C:\VirtIO\mountBoot\


# Step 3.5: Save and unmount the boot.wim image:

Dismount-windowsImage -Path C:\VirtIO\mountBoot\ -Save

#4.0: Perform the following steps to inject drivers into install.wim:
Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim



# 4.1.0 Mount the Windows Image Index 2 :
Mount-WindowsImage -Path C:\VirtIO\mountInstall\ -ImagePath C:\VirtIO\windows_temp\sources\install.wim -Index 2

# 4.1.1 Inject the  VirtIO drivers into the install.wim image:


Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\amd64\2k19\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\Balloon\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\fwcfg\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\NetKVM\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\qemupciserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\sriov\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viofs\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viogpudo\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioinput\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viorng\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioscsi\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viostor\2k19\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k19\amd64 -Recurse

#4.1.2 Save and unmount the install.wim image
Dismount-WindowsImage -Path C:\VirtIO\mountInstall\ -Save


# 5.1 Create ISO using OSCDIMG

cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg"

.\oscdimg -lWINSERV2K19_Standard_GUI_virtio -m -u2 -bC:\VirtIO\windows_temp\boot\etfsboot.com C:\VirtIO\windows_temp\ C:\VirtIO\WINSERV2K19_Standard_GUI_virtio.iso
 
Last edited:
Bash:
#Server 2K22 Standard GUI with Virtio drivers
#Server 2K22 Datacenter GUI with Virtio drivers

# This is based on the following guidance: 
# https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000bt28CAA
# https://pve.proxmox.com/wiki/Windows_guests_-_build_ISOs_including_VirtIO_drivers




#What you'll need: 

#    *PowerShell.
#    *Windows ADK (Deployment and Imaging Tools Environment: https://go.microsoft.com/fwlink/?linkid=2120254
#    *Windows 2k22 installation ISO.
#     *Virtio Driver Package ISO: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/ 
#    *Administrative privileges on your Windows admin workstation.

# Steps 1: Mount the following ISO's and note the Drive-letters (you'll need to addapt the script below):
# *Windows 2k22
# *Virtio drivers


#Step 2.1:Open Powershell as admin and create temp folders on your C: drive :

mkdir C:\VirtIO\windows_temp,C:\VirtIO\mountBoot,C:\VirtIO\mountInstall

#Step 2.2:Copy the mounted Windows ISO contents to the windows_temp folder: 

Copy-Item F:\* C:\VirtIO\windows_temp\ -Recurse

#Step 2.3: Change the image "C:\VirtIO\windows_temp\sources\"  files boot.wim and install.wim file permissions to read/write in the windows_temp directory

attrib -r C:\VirtIO\windows_temp\sources\*.wim /s

#Step 2.4: Verify the Image export: 

Get-windowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim


#Step 3.1: Inject drivers 

#Review and choose an index that belongs to "Microsoft Windows Setup" in boot.wim:

Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\boot.wim

# Step 3.2: Select Standard GUI Variant:

#Mount the boot.wim file for driver injection. Note the use of "-Index 2":
Mount-windowsImage -Path C:\VirtIO\mountBoot\ -ImagePath C:\VirtIO\windows_temp\sources\boot.wim -Index 2

# Step 3.3: Inject the Virtio drivers into the boot.vim


Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\amd64\2k22\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\Balloon\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\fwcfg\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\NetKVM\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\qemupciserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\sriov\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viofs\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viogpudo\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioinput\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viorng\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioscsi\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viostor\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k22\amd64 -Recurse


#Step 3.4:Use the following command to verify that drivers were injected.
Get-WindowsDriver -Path C:\VirtIO\mountBoot\


# Step 3.5: Save and unmount the boot.wim image:

Dismount-windowsImage -Path C:\VirtIO\mountBoot\ -Save

# 4.0: Perform the following steps to inject drivers into install.wim:
Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim



# 4.1.0 Mount the Windows Image Index 1 : 
Mount-WindowsImage -Path C:\VirtIO\mountInstall\ -ImagePath C:\VirtIO\windows_temp\sources\install.wim -Index 4

# 4.1.1 Inject the  VirtIO drivers into the install.wim image:


Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\amd64\2k22\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\Balloon\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\fwcfg\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\NetKVM\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\qemupciserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\sriov\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viofs\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viogpudo\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioinput\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viorng\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioscsi\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viostor\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k22\amd64 -Recurse

#4.1.2 Save and unmount the install.wim image
Dismount-WindowsImage -Path C:\VirtIO\mountInstall\ -Save


# 5.1 Create ISO using OSCDIMG

cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg"

.\oscdimg -lWINSERV2K22_Standard_GUI_virtio -m -u2 -bC:\VirtIO\windows_temp\boot\etfsboot.com C:\VirtIO\windows_temp\ C:\VirtIO\WINSERV2K22_Datacenter_GUI_virtio.iso





Bash:
#Server 2K22 Standard GUI with Virtio drivers

# This is based on the following guidance: 
# https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000bt28CAA
# https://pve.proxmox.com/wiki/Windows_guests_-_build_ISOs_including_VirtIO_drivers




#What you'll need: 

#    *PowerShell.
#    *Windows ADK (Deployment and Imaging Tools Environment: https://go.microsoft.com/fwlink/?linkid=2120254
#    *Windows 2k22 installation ISO.
#     *Virtio Driver Package ISO: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/ 
#    *Administrative privileges on your Windows admin workstation.

# Steps 1: Mount the following ISO's and note the Drive-letters (you'll need to addapt the script below):
# *Windows 2k22  (in this Guide it is D:)
# *Virtio drivers (in this Guide it is F:)


#Step 2.1: Open Powershell as admin and create temp folders on your C: drive :

mkdir C:\VirtIO\windows_temp,C:\VirtIO\mountBoot,C:\VirtIO\mountInstall

#Step 2.2: Copy the mounted Windows ISO contents to the windows_temp folder: 

Copy-Item F:\* C:\VirtIO\windows_temp\ -Recurse

#Step 2.3: Change the image "C:\VirtIO\windows_temp\sources\"  files boot.wim and install.wim file permissions to read/write in the windows_temp directory

attrib -r C:\VirtIO\windows_temp\sources\*.wim /s

#Step 2.4:
Verify the Image export: 

Get-windowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim


#Step 3.1: Inject drivers

#Review and choose an index that belongs to "Microsoft Windows Setup" in boot.wim:

Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\boot.wim

# Step 3.2:Mount the boot.wim file for driver injection. Note the use of "-Index 2":

Mount-windowsImage -Path C:\VirtIO\mountBoot\ -ImagePath C:\VirtIO\windows_temp\sources\boot.wim -Index 2

# Step 3.3: Inject the Virtio drivers into the boot.vim


Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\amd64\2k22\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\Balloon\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\fwcfg\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\NetKVM\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\qemupciserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\sriov\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viofs\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viogpudo\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioinput\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viorng\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioscsi\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\viostor\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountBoot\ -Driver G:\vioserial\2k22\amd64 -Recurse


#Step 3.4: Use "Get-WindowsDriver -Path C:\VirtIO\mountBoot\" command to verify that drivers were injected.

Get-WindowsDriver -Path C:\VirtIO\mountBoot\

# Step 3.5: Save and unmount the boot.wim image:

Dismount-windowsImage -Path C:\VirtIO\mountBoot\ -Save

# 4.0: Perform the following steps to inject drivers into install.wim:
Get-WindowsImage -ImagePath C:\VirtIO\windows_temp\sources\install.wim



# 4.1.0 Mount the Windows Image Index 1 : 
Mount-WindowsImage -Path C:\VirtIO\mountInstall\ -ImagePath C:\VirtIO\windows_temp\sources\install.wim -Index 2

# 4.1.1 Inject the  VirtIO drivers into the install.wim image:


Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\amd64\2k22\ -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\Balloon\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\fwcfg\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\NetKVM\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\qemupciserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\sriov\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viofs\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viogpudo\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioinput\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viorng\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioscsi\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\viostor\2k22\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO\mountInstall\ -Driver G:\vioserial\2k22\amd64 -Recurse

#4.1.2 Save and unmount the install.wim image
Dismount-WindowsImage -Path C:\VirtIO\mountInstall\ -Save


# 5.1 Create ISO using OSCDIMG

cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg"

.\oscdimg -lWINSERV2K22_Standard_GUI_virtio -m -u2 -bC:\VirtIO\windows_temp\boot\etfsboot.com C:\VirtIO\windows_temp\ C:\VirtIO\WINSERV2K22_Standard_GUI_virtio.iso
 
changelog: Script fixed for Windows Server 2025 on 2025/06/11

The Windows 2025 iso can be gotton directly from Microsoft: here
This was performed with virtio-win-0.1.271 drivers from here
Latest ADK (ADK 10.1.26100.2454 (December 2024)) used from here

Code:
#Server 2K22 Standard GUI with Virtio drivers

# This is based on the following guidance:
# https://portal.nutanix.com/page/documents/kbs/details?targetId=kA00e000000bt28CAA
# https://pve.proxmox.com/wiki/Windows_guests_-_build_ISOs_including_VirtIO_drivers




#What you'll need:

#    *PowerShell.
#    *Windows ADK (Deployment and Imaging Tools Environment: https://go.microsoft.com/fwlink/?linkid=2120254
#    *Windows 2k22 installation ISO.
#     *Virtio Driver Package ISO: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/
#    *Administrative privileges on your Windows admin workstation.

# Steps 1: Mount the following ISO's and note the Drive-letters (you'll need to addapt the script below):
# *Windows 2k22  (in this Guide it is D:)
# *Virtio drivers (in this Guide it is F:)


#Step 2.1: Open Powershell as admin and create temp folders on your C: drive :

mkdir C:\VirtIO25\windows_temp,C:\VirtIO25\mountBoot,C:\VirtIO25\mountInstall

#Step 2.2: Copy the mounted Windows ISO contents to the windows_temp folder:

Copy-Item F:\* C:\VirtIO25\windows_temp\ -Recurse

#Step 2.3: Change the image "C:\VirtIO25\windows_temp\sources\"  files boot.wim and install.wim file permissions to read/write in the windows_temp directory

attrib -r C:\VirtIO25\windows_temp\sources\*.wim /s

#Step 2.4:
Verify the Image export:

Get-windowsImage -ImagePath C:\VirtIO25\windows_temp\sources\install.wim


#Step 3.1: Inject drivers

#Review and choose an index that belongs to "Microsoft Windows Setup" in boot.wim:

Get-WindowsImage -ImagePath C:\VirtIO25\windows_temp\sources\boot.wim

# Step 3.2:Mount the boot.wim file for driver injection. Note the use of "-Index 2":

Mount-windowsImage -Path C:\VirtIO25\mountBoot\ -ImagePath C:\VirtIO25\windows_temp\sources\boot.wim -Index 2

# Step 3.3: Inject the Virtio drivers into the boot.vim


Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\amd64\2k25\ -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\Balloon\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\fwcfg\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\NetKVM\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\qemupciserial\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\sriov\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\viofs\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\viogpudo\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\vioinput\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\viorng\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\vioscsi\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\vioserial\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\viostor\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountBoot\ -Driver G:\vioserial\2k25\amd64 -Recurse


#Step 3.4: Use "Get-WindowsDriver -Path C:\VirtIO25\mountBoot\" command to verify that drivers were injected.

Get-WindowsDriver -Path C:\VirtIO25\mountBoot\

# Step 3.5: Save and unmount the boot.wim image:

Dismount-windowsImage -Path C:\VirtIO25\mountBoot\ -Save

# 4.0: Perform the following steps to inject drivers into install.wim:
Get-WindowsImage -ImagePath C:\VirtIO25\windows_temp\sources\install.wim



# 4.1.0 Mount the Windows Image Index 1 :
Mount-WindowsImage -Path C:\VirtIO25\mountInstall\ -ImagePath C:\VirtIO25\windows_temp\sources\install.wim -Index 2

# 4.1.1 Inject the  VirtIO drivers into the install.wim image:


Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\amd64\2k25\ -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\Balloon\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\fwcfg\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\NetKVM\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\qemupciserial\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\sriov\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\viofs\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\viogpudo\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\vioinput\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\viorng\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\vioscsi\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\vioserial\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\viostor\2k25\amd64 -Recurse
Add-WindowsDriver -Path C:\VirtIO25\mountInstall\ -Driver G:\vioserial\2k25\amd64 -Recurse

#4.1.2 Save and unmount the install.wim image
Dismount-WindowsImage -Path C:\VirtIO25\mountInstall\ -Save


# 5.1 Create ISO using OSCDIMG

cd "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg"

.\oscdimg -lWINSERV2K25_Standard_GUI_virtio -m -u2 -bC:\VirtIO25\windows_temp\boot\etfsboot.com C:\VirtIO25\windows_temp\ C:\VirtIO25\WINSERV2K25_Standard_GUI_virtio.iso
 
Last edited:
  • Like
Reactions: aufwiz