1

Virtualization is very popular nowadays. When we use the Linux desktop environment, we can directly use kernel-based virtualization (KVM) to create virtual machines and install other types of operating systems libvirt and QEMU On Linux-based servers, virtual machine environments can also be implemented through KVM-based virtualization solutions such as oVirt or PVE

When we want to install relatively new Windows (such as Windows 10, Windows Server 2019, etc.) through the official iso system image, when we enter the choice of installation disk, we will find that the created virtual disk cannot be found, as shown in the following figure

win10-no-driver

This is because Widnows in the official iso image does not include the virtio-win driver for KVM, so we can load the corresponding driver of virtio-win based on the Windows iso image, and then create a new one that contains the virtio-win driver. The iso image file.

For more information about virtio-win, please refer to https://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers .

Prerequisites

In order to create an iso image file after loading the virtio-win driver, we need the following preparations:

  1. Windows 10 working system with administrator rights and install Windows ADK
  2. Windows 10 installation iso file (here, Windows 10 is used as an example)
  3. virtio-win driver iso file ( https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.196-1/virtio-win-0.1.196 .iso)
  4. UltraISO tool

Ready to work

Create working directory

Assuming that you have drive D on your Windows 10 system, then we create a corresponding working directory on drive D, open PowerShell with administrator privileges, and execute

PS D:\> mkdir D:\mnt\windows_temp,D:\mnt\boot,D:\mnt\install,D:\virtio-win

Extract Windows installation files

Use the UltraISO tool to open the iso file of windows 10 and extract all the files to the directory *D:\mnt\windows_temp*

ultraiso-extra-win10

Then authorize reading and writing to the Windows image file

PS D:\> attrib -r C:\mnt\windows_temp\sources\*.wim /s

Extract virtio driver files

Use UltraISO to open the downloaded iso file of virtio-win, and extract it to the directory *D:\virtio-win*, and then check which w10 (for windows10) drivers are available

virtio-w10-drivers

We can see that in the 0.1.196 version, the following w10 (64-bit) drivers are included. In order to facilitate the following command to load all the drivers, we put these drivers in a directory again

PS D:\> cd virtio-win\
PS D:\virtio-win\> mkdir w10
PS D:\virtio-win\> cp -r .\Balloon\w10\amd64\ .\w10\Balloon
PS D:\virtio-win\> cp -r .\NetKVM\w10\amd64\ .\w10\NetKVM
PS D:\virtio-win\> cp -r .\pvpanic\w10\amd64\ .\w10\pvpanic
PS D:\virtio-win\> cp -r .\qemufwcfg\w10\amd64\ .\w10\qemufwcfg
PS D:\virtio-win\> cp -r .\qemupciserial\w10\amd64\ .\w10\qemupciserial
PS D:\virtio-win\> cp -r .\qxldod\w10\amd64\ .\w10\qxldod
PS D:\virtio-win\> cp -r .\sriov\w10\amd64\ .\w10\sriov
PS D:\virtio-win\> cp -r .\viofs\w10\amd64\ .\w10\viofs
PS D:\virtio-win\> cp -r .\viogpudo\w10\amd64\ .\w10\viogpudo
PS D:\virtio-win\> cp -r .\vioinput\w10\amd64\ .\w10\vioinput
PS D:\virtio-win\> cp -r .\viorng\w10\amd64\ .\w10\viorng
PS D:\virtio-win\> cp -r .\vioscsi\w10\amd64\ .\w10\vioscsi
PS D:\virtio-win\> cp -r .\vioserial\w10\amd64\ .\w10\vioserial
PS D:\virtio-win\> cp -r .\viostor\w10\amd64\ .\w10\viostor

If you are creating another version of Windows system, such as Windows Server 2019, extract the driver in the corresponding directory (2k19/).

Load virtio driver

Need to load the virtio driver to the Windows image file boot.wim and install.wim .

Load the driver to boot.wim

Mount the extracted D:\mnt\ \sources\boot.wim 160e7211b428ae file to the directory *D:\mnt\boot*:

Get the index of the image file first

PS D:\> Get-WindowsImage -ImagePath D:\mnt\windows_temp\sources\boot.wim

ImageIndex       : 1
ImageName        : Microsoft Windows PE (x64)
ImageDescription : Microsoft Windows PE (x64)
ImageSize        : 1,657,563,910 bytes

ImageIndex       : 2
ImageName        : Microsoft Windows Setup (x64)
ImageDescription : Microsoft Windows Setup (x64)
ImageSize        : 1,809,575,703 bytes

Then mount index 2

PS D:\> Mount-WindowsImage -Path D:\mnt\boot\ -ImagePath D:\mnt\windows_temp\sources\boot.wim -Index 2

Path          : D:\mnt\boot\
Online        : False
RestartNeeded : False

The next step is to load the driver we extracted earlier

PS D:\> Add-WindowsDriver -Path D:\mnt\boot\ -Driver D:\virtio-win\w10\ -Recurse

You can use the following command to check whether the driver has been loaded

PS D:\> Get-WindowsDriver -Path D:\mnt\boot\

After confirming that the loading is successful, unmount the image mount and save

PS D:\> Dismount-WindowsImage -Path D:\mnt\boot\ -Save

Load the driver to install.wim

Similarly, first check install.wim mirror (different indexes specify the version in the same iso file)

PS D:\> Get-WindowsImage -ImagePath D:\mnt\windows_temp\sources\install.wim

ImageIndex       : 1
ImageName        : Windows 10 教育版
ImageDescription : Windows 10 教育版
ImageSize        : 15,543,804,395 bytes

ImageIndex       : 2
ImageName        : Windows 10 企业版
ImageDescription : Windows 10 企业版
ImageSize        : 15,543,958,390 bytes

ImageIndex       : 3
ImageName        : Windows 10 专业版
ImageDescription : Windows 10 专业版
ImageSize        : 15,540,672,790 bytes

ImageIndex       : 4
ImageName        : Windows 10 专业教育版
ImageDescription : Windows 10 专业教育版
ImageSize        : 15,543,742,813 bytes

ImageIndex       : 5
ImageName        : Windows 10 专业工作站版
ImageDescription : Windows 10 专业工作站版
ImageSize        : 15,543,773,604 bytes

Mount the version of the driver you want to load, such as the professional version

PS D:\> Mount-WindowsImage -Path D:\mnt\install\ -ImagePath D:\mnt\windows_temp\sources\install.wim -Index 3

Path          : D:\mnt\install\
Online        : False
RestartNeeded :False

Then load the driver

PS D:\> Add-WindowsDriver -Path D:\mnt\install\ -Driver D:\virtio-win\w10\ -Recurse

Uninstall save

PS D:\> Dismount-WindowsImage -Path D:\mnt\install\ -Save

In the same way, you can continue to mount other indexes (versions), perform the above operations, load the driver, and then save.

Create a new iso image file

Here we use the oscdimg tool that comes with the Windows ADK to create the ISO file. After installing the Windows ADK tool, enter the directory *C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\ amd64\Oscdimg*

PS D:\> cd 'C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg'

PS C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg> .\oscdimg.exe -lcn_windows_10_virtio -m -u2 -bD:\mnt\windows_temp\boot\etfsboot.com D:\mnt\windows_temp\ D:\ISOFiles\cn_windows_10_virtio_x64.iso

Just thinking about the above command will create a file named cn_windows_10_virtio_x64.iso in the directory *D:\ISOFiles*.

Finally, try to use the newly created iso file to install the virtual machine system. When choosing the disk drive, we can see the virtual disk we created

win10-with-driver

Then you can install it normally.

to sum up

This article uses the iso file of Windows 10 as an example to demonstrate how to load the virtio-win driver and create a new iso file so that the virtual machine disk can be successfully loaded for Windows installation in a KVM-based virtual environment. Of course, some virtual manufacturers will directly provide the corresponding signature driver, and you can load the corresponding driver by adding an additional virtual CD drive during the installation process.

https://mengz.dev/posts/windows/create-windows10-iso-with-virtio-drivers/


梦哲
74 声望58 粉丝

寻找人生的意义!