现在虚拟化曾经十分风行,当咱们应用Linux桌面环境时,能够通过装置libvirt和QEMU间接应用基于内核的虚拟化(KVM)来创立虚拟机并装置其余类型的操作系统。在基于Linux的服务器上,也能够通过oVirt或者PVE等基于KVM的虚拟化计划来实现虚拟机环境。
当咱们想通过官网iso零碎镜像装置比拟新的Windows(例如Windows 10,Windows Server 2019等),在进入到抉择装置磁盘,会发现找不到创立的虚构磁盘,如下图所示
这是因为在官网的iso镜像中的Widnows未蕴含针对KVM的virtio-win驱动,因而咱们能够基于Windows的iso镜像,加载virtio-win的相应驱动之后,从新创立一个蕴含了virtio-win驱动的iso镜像文件。
对于virtio-win的更多信息,能够参考 https://www.linux-kvm.org/pag... 。
前提条件
为了创立一个加载virtio-win驱动之后的iso镜像文件,咱们须要以下筹备:
- 具备管理员权限的Windows 10工作零碎并装置Windows ADK
- Windows 10的装置iso文件(这里以Windows 10作为例子)
- virtio-win驱动的iso文件 (https://fedorapeople.org/grou...
- UltraISO工具
筹备工作
创立工作目录
假如在你的Windows 10零碎上有D盘,那咱们在D盘创立相应的工作目录,以管理员权限关上PowerShell,并执行
PS D:\> mkdir D:\mnt\windows_temp,D:\mnt\boot,D:\mnt\install,D:\virtio-win
提取Windows安装文件
应用UltraISO工具关上windows 10的iso文件,并将所有文件提取到目录 *D:\mnt\windows_temp* 下
而后给Windows的镜像文件受权读写
PS D:\> attrib -r C:\mnt\windows_temp\sources\*.wim /s
提取virtio驱动文件
应用UltraISO关上下载的virtio-win的iso文件,同样提取到目录 *D:\virtio-win* 下,而后查看有哪些w10(针对windowns10)的驱动
咱们能够看到在 0.1.196 版本中,蕴含了以下w10(64位)的驱动,为了不便前面一条命令加载所有驱动,咱们把这些驱动从新放到一个目录下
PS D:\> cd virtio-win\PS D:\virtio-win\> mkdir w10PS D:\virtio-win\> cp -r .\Balloon\w10\amd64\ .\w10\BalloonPS D:\virtio-win\> cp -r .\NetKVM\w10\amd64\ .\w10\NetKVMPS D:\virtio-win\> cp -r .\pvpanic\w10\amd64\ .\w10\pvpanicPS D:\virtio-win\> cp -r .\qemufwcfg\w10\amd64\ .\w10\qemufwcfgPS D:\virtio-win\> cp -r .\qemupciserial\w10\amd64\ .\w10\qemupciserialPS D:\virtio-win\> cp -r .\qxldod\w10\amd64\ .\w10\qxldodPS D:\virtio-win\> cp -r .\sriov\w10\amd64\ .\w10\sriovPS D:\virtio-win\> cp -r .\viofs\w10\amd64\ .\w10\viofsPS D:\virtio-win\> cp -r .\viogpudo\w10\amd64\ .\w10\viogpudoPS D:\virtio-win\> cp -r .\vioinput\w10\amd64\ .\w10\vioinputPS D:\virtio-win\> cp -r .\viorng\w10\amd64\ .\w10\viorngPS D:\virtio-win\> cp -r .\vioscsi\w10\amd64\ .\w10\vioscsiPS D:\virtio-win\> cp -r .\vioserial\w10\amd64\ .\w10\vioserialPS D:\virtio-win\> cp -r .\viostor\w10\amd64\ .\w10\viostor
如果创立的是其余版本的Windows零碎,例如Windows Server 2019,则提取对应目录(2k19/)下的驱动。
加载virtio驱动
须要加载virtio驱动到Windows镜像文件 boot.wim 和 install.wim 。
加载驱动到boot.wim
挂载提取进去的 D:\mnt\windows_temp\sources\boot.wim 文件到目录 *D:\mnt\boot* :
先获取镜像文件的索引
PS D:\> Get-WindowsImage -ImagePath D:\mnt\windows_temp\sources\boot.wimImageIndex : 1ImageName : Microsoft Windows PE (x64)ImageDescription : Microsoft Windows PE (x64)ImageSize : 1,657,563,910 bytesImageIndex : 2ImageName : Microsoft Windows Setup (x64)ImageDescription : Microsoft Windows Setup (x64)ImageSize : 1,809,575,703 bytes
而后挂载索引2
PS D:\> Mount-WindowsImage -Path D:\mnt\boot\ -ImagePath D:\mnt\windows_temp\sources\boot.wim -Index 2Path : D:\mnt\boot\Online : FalseRestartNeeded : False
接下来就是加载咱们之前提取进去的驱动
PS D:\> Add-WindowsDriver -Path D:\mnt\boot\ -Driver D:\virtio-win\w10\ -Recurse
能够应用上面的命令来查看驱动是否曾经加载进去
PS D:\> Get-WindowsDriver -Path D:\mnt\boot\
确定加载胜利后,卸载镜像挂载并保留
PS D:\> Dismount-WindowsImage -Path D:\mnt\boot\ -Save
加载驱动到install.wim
同样,首先查看 install.wim 镜像的索引(不同索引指定了同一iso文件里的版本)
PS D:\> Get-WindowsImage -ImagePath D:\mnt\windows_temp\sources\install.wimImageIndex : 1ImageName : Windows 10 教育版ImageDescription : Windows 10 教育版ImageSize : 15,543,804,395 bytesImageIndex : 2ImageName : Windows 10 企业版ImageDescription : Windows 10 企业版ImageSize : 15,543,958,390 bytesImageIndex : 3ImageName : Windows 10 专业版ImageDescription : Windows 10 专业版ImageSize : 15,540,672,790 bytesImageIndex : 4ImageName : Windows 10 业余教育版ImageDescription : Windows 10 业余教育版ImageSize : 15,543,742,813 bytesImageIndex : 5ImageName : Windows 10 业余工作站版ImageDescription : Windows 10 业余工作站版ImageSize : 15,543,773,604 bytes
挂载想要加载驱动的版本,例如专业版
PS D:\> Mount-WindowsImage -Path D:\mnt\install\ -ImagePath D:\mnt\windows_temp\sources\install.wim -Index 3Path : D:\mnt\install\Online : FalseRestartNeeded :False
而后加载驱动
PS D:\> Add-WindowsDriver -Path D:\mnt\install\ -Driver D:\virtio-win\w10\ -Recurse
卸载保留
PS D:\> Dismount-WindowsImage -Path D:\mnt\install\ -Save
同理,能够持续挂载其余索引(版本),执行以上操作,加载驱动,而后保留。
创立新的iso镜像文件
这里咱们应用Windows ADK带的 oscdimg 工具来创立ISO文件,装置完Windows ADK工具之后,进入目录 *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
只想如上命令后,就会在目录 *D:\ISOFiles* 目录下创立出一个名为 cn_windows_10_virtio_x64.iso 的文件。
最初尝试应用新创建的iso文件来装置虚拟机零碎,在抉择抉择磁盘驱动器时,咱们就能够看到咱们创立的虚构磁盘了
接下来就能够失常装置了。
总结
本文以Windows 10的iso文件作为示例,演示了如何将virtio-win驱动加载进去,并且创立新的iso文件,使得在基于KVM的虚拟环境也能够顺利加载虚拟机磁盘进行Windows的装置。当然某些虚构厂家也会间接提供相应的签名驱动,在装置过程中能够通过多减少一个虚构CD驱动器来加载相应的驱动。
https://mengz.dev/posts/windo...