Virtio 是 KVM 虚拟环境下针对 I/O 虚拟化的最主要的一个通用框架。
向Windows Server 2016系统添加virtio(Virtio)驱动,集成virtio驱动的Windows Server 2016的ISO镜像,在Vultr测试通过。
向Windows Server 2016添加VirtIO驱动教程 集成virtio驱动的Windows Server 2016
步骤
1、安装软碟通(UltraISO)和Haozip, Haozip附带的虚拟光驱也要装上
2、安装ADK部署工具 https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit
3、加载系统镜像cn_windows_server_2016_x64_dvd_9327743.iso到虚拟光驱
4、将boot.wim和install.wim发送到C盘
5、在C盘创建文件夹mount,将驱动解压到C盘virtio
6、以管理员权限运行”Windows PowerShell”或”Command”进入WAIK目录使用DISM (部署映像服务和管理)
C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools
查看wim文件包含的版本个数
dism /get-wiminfo /wimfile:C:/boot.wim 2
dism /get-wiminfo /wimfile:C:/install.wim 4
PS C:\Program Files\Windows AIK\Tools\PETools> dism /get-wiminfo /wimfile:C:/install.wim
索引: 1
名称: Windows Server 2016 Standard
描述: 此选项(推荐使用)仅安装运行大多数服务器角色和应用程序所需的内容,从而减少了
管理和维护工作量。它不包括 GUI,但你可以使用 Windows PowerShell 或其他工具通过本
地或远程方式完全管理服务器。有关更多详细信息,请参阅“Windows Server 安装选项”
。
大小: 9,615,846,310 个字节
索引: 2
名称: Windows Server 2016 Standard (桌面体验)
描述: 当需要 GUI 时,此选项很有用(例如,为无法在服务器核心安装上运行的应用程序提
供向后兼容性)。支持所有服务器角色和功能。有关更多详细信息,请参阅“Windows Serve
r 安装选项”。
大小: 15,599,232,154 个字节
索引: 3
名称: Windows Server 2016 Datacenter
描述: 此选项(推荐使用)仅安装运行大多数服务器角色和应用程序所需的内容,从而减少了
管理和维护工作量。它不包括 GUI,但你可以使用 Windows PowerShell 或其他工具通过本
地或远程方式完全管理服务器。有关更多详细信息,请参阅“Windows Server 安装选项”
。
大小: 9,617,008,508 个字节
索引: 4
名称: Windows Server 2016 Datacenter (桌面体验)
描述: 当需要 GUI 时,此选项很有用(例如,为无法在服务器核心安装上运行的应用程序提
供向后兼容性)。支持所有服务器角色和功能。有关更多详细信息,请参阅“Windows Serve
r 安装选项”。
大小: 15,595,966,258 个字节
7、添加virtio驱动到install.wim
dism /mount-wim /wimfile:C:/install.wim /index:1 /mountdir:C:/mount 挂载install.wim映像第一个索引
添加驱动
dism /mount-wim /wimfile:C:/install.wim /index:1 /mountdir:C:/mount
dism /image:C:\mount /add-driver /driver:C:\virtio\NetKVM\2k16\amd64\netkvm.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\vioscsi\2k16\amd64\vioscsi.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\viostor\2k16\amd64\viostor.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\viorng\2k16\amd64\viorng.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\vioserial\2k16\amd64\vioser.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\Balloon\2k16\amd64\balloon.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\qxldod\2k16\amd64\qxldod.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\pvpanic\2k16\amd64\pvpanic.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\qemupciserial\2k16\amd64\qemupciserial.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\qemufwcfg\2k16\amd64\qemufwcfg.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\vioinput\2k16\amd64\vioinput.inf
Dism /Image:C:\mount /Add-Package /PackagePath:E:\HOTFIX #添加补丁文件
dism /image:C:\mount /get-drivers #获取添加的驱动信息
dism /unmount-wim /mountdir:C:/mount /commit #卸载
添加virtio驱动后查看一下安装信息,查看是否添加到映像里面。如果驱动没经过微软认证的话,记得在添加驱动那一步结尾加上”/forceunsigned”参数
dism /image:C:\mount /get-drivers
dism /unmount-wim /mountdir:C:/mount /commit 卸载映像
第二个索引
dism /mount-wim /wimfile:C:/install.wim /index:2 /mountdir:C:/mount 挂载install.wim映像第二个索引
....
....
第三个索引
dism /mount-wim /wimfile:C:/install.wim /index:3 /mountdir:C:/mount 挂载install.wim映像第三个索引
....
....
第四个索引
dism /mount-wim /wimfile:C:/install.wim /index:4 /mountdir:C:/mount 挂载install.wim映像第四个索引
....
....
7、添加virtio驱动到boot.wim
dism /get-wiminfo /wimfile:C:/boot.wim
部署映像服务和管理工具
版本: 10.0.14393.0
映像的详细信息: C:/boot.wim
索引: 1
名称: Microsoft Windows PE (x64)
描述: Microsoft Windows PE (x64)
大小: 1,745,492,664 个字节
索引: 2
名称: Microsoft Windows Setup (x64)
描述: Microsoft Windows Setup (x64)
大小: 1,863,239,432 个字节
dism /mount-wim /wimfile:C:/boot.wim /index:1-2 /mountdir:C:/mount
dism /image:C:\mount /add-driver /driver:C:\virtio\NetKVM\2k16\amd64\netkvm.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\vioscsi\2k16\amd64\vioscsi.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\viostor\2k16\amd64\viostor.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\viorng\2k16\amd64\viorng.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\vioserial\2k16\amd64\vioser.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\Balloon\2k16\amd64\balloon.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\qxldod\2k16\amd64\qxldod.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\pvpanic\2k16\amd64\pvpanic.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\qemupciserial\2k16\amd64\qemupciserial.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\qemufwcfg\2k16\amd64\qemufwcfg.inf
dism /image:C:\mount /add-driver /driver:C:\virtio\vioinput\2k16\amd64\vioinput.inf
Dism /Image:C:\mount /Add-Package /PackagePath:E:\HOTFIX #添加补丁文件
dism /image:C:\mount /get-drivers #获取添加的驱动信息
dism /unmount-wim /mountdir:C:/mount /commit #卸载
----------------------------------------
NetKVM/: Virtio Network driver
viostor/: Virtio Block driver
vioscsi/: Virtio SCSI driver
viorng/: Virtio RNG driver
vioser/: Virtio serial driver
Balloon/: Virtio Memory Balloon driver
qxl/: QXL graphics driver for Windows 7 and earlier. (build virtio-win-0.1.103-1 and later)
qxldod/: QXL graphics driver for Windows 8 and later. (build virtio-win-0.1.103-2 and later)
pvpanic/: QEMU pvpanic device driver (build virtio-win-0.1.103-2 and later)
guest-agent/: QEMU Guest Agent 32bit and 64bit MSI installers
qemupciserial/: QEMU PCI serial device driver
*.vfd: VFD floppy images for using during install of Windows XP
-----------------------------------------------------------------------------------
添加virtio驱动脚本(未测试)
@echo off
set bootvar=0
set /p bootwimpath=请输入wim文件完整路径例如(D:\boot.wim):
set /p installlwimpath=请输入wim文件完整路径例如(D:\install.wim):
set /p temppath=请输入临时目录完整路径确保文件夹为空(例如:D:\temp):
set /p driverpath=请输入要加入的驱动路径(例如:D:\win2008r2):
dism /get-wiminfo /wimfile:%bootwimpath%
set /p bootcount=请输入当前boot.wim文件所包含的版本个数:
dism /get-wiminfo /wimfile:%installlwimpath%
set /p installcount=请输入当前install.wim文件所包含的版本个数:
rem ************循环开始了
:bootcontinue
set /a bootvar+=1
echo boot.wim第%bootvar%次循环 >>dism.log
echo ====================================================================================== >>dism.log
echo 为boot.wim加载驱动 >> dism.log
dism /mount-wim /wimfile:%bootwimpath% /index:%bootvar% /mountdir:%temppath% >>dism.log
dism /image:%temppath% /add-driver /driver:%driverpath% /recurse /forceunsigned >>dism.log
dism /unmount-wim /mountdir:%temppath% /commit >>dism.log
echo 等待5s准备导入下一版本,如需取消请立即按Ctrl+C >>dism.log
rem 等待10秒 ping本机10次不使用默认的次数,nul是不显示ping信息:
@ping -n 5 127.1>nul
if %bootvar% lss %bootcount% goto bootcontinue
rem ************循环结束了
echo boot.wim循环执行完毕 >>dism.log
set varinstall=0
rem ************循环开始了
:installcontinue
set /a varinstall+=1
echo install.wim第%varinstall%次循环 >>dism.log
echo ====================================================================================== >>dism.log
dism /mount-wim /wimfile:%installlwimpath% /index:%varinstall% /mountdir:%temppath% >>dism.log
dism /image:%temppath% /add-driver /driver:%driverpath% /recurse /forceunsigned >>dism.log
dism /unmount-wim /mountdir:%temppath% /commit >>dism.log
echo 等待5s准备导入下一版本,如需取消请立即按Ctrl+C >>dism.log
rem 等待10秒 ping本机10次不使用默认的次数,nul是不显示ping信息:
@ping -n 5 127.1>nul
if %varinstall% lss %installcount% goto installcontinue
rem ************循环结束了
echo install.wim循环执行完毕 >>dism.log
pause
在D:根目录创建一个test.bat文件,将上面脚本拷入文件中,执行脚本,输入所需路径参数 ,boot.wim版本数为2
-----------------------------------------------------------------------------------
8、封装处理
使用UltraISO, 打开cn_windows_server_2016_x64_dvd_9327743.iso将镜像里的boot.wim和install.wim删除(路径:/sources),
再将刚开始从镜像里提取到c盘的boot.wim和install.wim添加进去,然后保存即可。
Haozip http://haozip.com/
Windows 10 (Windows Server 2016) ADK https://developer.microsoft.com/en-us/windows/hardware/windows-assessment-deployment-kit
virtio驱动下载地址 https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
virtio驱动相关说明 http://pve.proxmox.com/wiki/Windows_VirtIO_Drivers
DISM – 部署映像服务和管理 (DISM) 技术参考 http://technet.microsoft.com/zh-cn/library/hh824821.aspx
集成virtio驱动的Windows Server 2016的ISO镜像 http://arv.asuhu.com/cn_windows_server_2016_vl_x64_dvd_11636695_vitio_20180415.iso
集成virtio驱动的Windows 10 的ISO镜像 http://arv.asuhu.com/cn_windows_10_multi-edition_vl_version_1709_updated_dec_2017_x64_dvd_100406208_virtio_20180202.iso