windows: 添加 intel 网卡驱动

This commit is contained in:
bin456789 2025-03-10 22:21:46 +08:00
parent 6a93bcc185
commit 243bdb0831
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
4 changed files with 233 additions and 17 deletions

View File

@ -1,4 +1,4 @@
<!-- markdownlint-disable MD028 MD033 MD045 -->
<!-- markdownlint-disable MD028 MD033 MD045 MD053 -->
# reinstall
@ -396,12 +396,37 @@ bash reinstall.sh windows \
#### The following drivers will automatic download and install as needed, without the need for manual addition
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1))
- XEN ([~~XEN~~ (unsigned)](https://xenproject.org/resources/downloads/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html))
- AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html))
- GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Display Adapter](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display))
- Azure ([MANA Network Adapter](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows))
- Intel ([VMD Storage Controller](https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html))
- Virtio ([Virtio][virtio-virtio][Alibaba Cloud][virtio-aliyun])
- XEN ([~~XEN~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws])
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
- Azure ([MANA Network Adapter][azure-mana])
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
[xen-xen]: https://xenproject.org/resources/downloads/
[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade
[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html
[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
[intel-vmd]: https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html
[intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html
[intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
[intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html
[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
[intel-nic-2008-r2-sha256]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html
[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html
[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html
#### How to Specify the Image Name `--image-name`

View File

@ -1,4 +1,4 @@
<!-- markdownlint-disable MD028 MD033 MD045 -->
<!-- markdownlint-disable MD028 MD033 MD045 MD053 -->
# reinstall
@ -396,12 +396,37 @@ bash reinstall.sh windows \
#### 以下驱动会自动按需下载安装,无需手动添加
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1))
- XEN ([~~XEN~~ (未签名)](https://xenproject.org/resources/downloads/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html))
- AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html))
- GCP ([gVNIC 网卡](https://cloud.google.com/compute/docs/networking/using-gvnic)、[GGA 显卡](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display))
- Azure ([MANA 网卡](https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows))
- Intel ([VMD 存储控制器](https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html))
- Virtio ([Virtio][virtio-virtio][阿里云][virtio-aliyun])
- XEN ([~~XEN~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws])
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
- Azure ([MANA 网卡][azure-mana])
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
[xen-xen]: https://xenproject.org/resources/downloads/
[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade
[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html
[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
[intel-vmd]: https://www.intel.com/content/www/us/en/download/720755/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-11th-up-to-13th-gen-platforms.html
[intel-nic-7-sha1]: https://www.intel.com/content/www/us/en/download/15590/29323/intel-network-adapter-driver-for-windows-7-final-release.html
[intel-nic-7-sha256]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
[intel-nic-8]: https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html
[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
[intel-nic-2008-r2-sha256]: https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html
[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html
[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html
#### 如何填写映像名称 `--image-name`

140
trans.sh
View File

@ -5120,6 +5120,22 @@ is_absolute_path() {
[[ "$1" = "/*" ]]
}
# 注意使用方法是 list=$(list_add "$list" "$item_to_add")
list_add() {
local list=$1
local item_to_add=$2
if [ -n "$list" ]; then
echo "$list"
fi
echo "$item_to_add"
}
is_list_has() {
local list=$1
local item=$2
echo "$list" | grep -qFx "$item"
}
install_windows() {
get_wim_prop() {
wim=$1
@ -5420,10 +5436,122 @@ install_windows() {
;;
esac
# intel 网卡驱动
# 官网没有提供 vista/2008 驱动
# win7 驱动 inf/ndis 不支持 vista/2008
if is_nt_ver_ge 6.1 && { [ "$arch_wim" = x86 ] || [ "$arch_wim" = x86_64 ]; } &&
grep -iq 8086 /sys/class/net/e*/device/vendor; then
add_driver_intel_nic
fi
# 自定义驱动
add_driver_custom
}
add_driver_intel_nic() {
info "Add drivers: Intel NIC"
arch_intel=$(
case "$arch_wim" in
x86) echo 32 ;;
x86_64) echo x64 ;;
esac
)
file=$(
case "$product_ver" in
'7' | '2008 r2') echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名
# '7' | '2008 r2') echo 18713/eng/prowin${arch_intel}legacy.exe ;; # 25.0 有部分文件是 sha256 签名
'8') echo 21642/eng/prowin${arch_intel}.exe ;;
'8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;;
'2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;;
*) echo 845886/Wired_driver_30.0_${arch_intel}.zip ;;
esac
)
# intel 禁止了 aria2 下载
# download https://downloadmirror.intel.com/$file $drv/intel.zip
wget https://downloadmirror.intel.com/$file -O $drv/intel.zip
# inf 可能是 UTF-16 LE因此用 rg 搜索
# 用 busybox unzip 解压 win10 驱动时,路径和文件名会粘在一起
apk add unzip ripgrep
# win7 驱动是 .exe 解压不会报错
# win10 驱动是 .zip 解压反而会报错,目测 zip 文件有问题
# 在 windows 下解压 win8 的驱动会提示 checksum 错误
unzip -o -d $drv/intel/ $drv/intel.zip || true
# Vista RTM 版本号是 6000 NDIS 6.0
# 2008 RTM 版本号是 6001 NDIS 6.1
# 找出驱动文件夹对应的最低系统版本
# 1. 驱动可能限制 windows client/server但我们不区分
# 如果装不了也没关系。如果能装但不加载,用户也可以在硬件管理器强制加载驱动
# 2. 官网写着 win10 驱动要求 RS5 1809但是驱动包里有 NDIS65 文件夹,也就是支持 10240
# 3. 有可能 NDIS65 文件夹实际要求 NDIS 6.51?但是先不管
# https://learn.microsoft.com/en-us/windows-hardware/drivers/network/overview-of-ndis-versions
min_support_map=$(cat <<EOF |
6000 NDIS60
6001 NDIS61
7600 NDIS62
9200 NDIS63
9600 NDIS64
10240 NDIS65
14393 NDIS66
15063 NDIS67
16299 NDIS68
20348 WS2022
22000 W11
26100 WS2025
EOF
case "$windows_type" in
client) grep -E 'NDIS|^WS' ;;
server) grep -E 'NDIS|WS' ;;
esac)
for ethx in $(get_eths); do
sys_dir=$(get_sys_dir_for_eth $ethx)
ven=$(cat $sys_dir/vendor | sed 's/^0x//')
dev=$(cat $sys_dir/device | sed 's/^0x//')
subsys=$(cat $sys_dir/subsystem_device $sys_dir/subsystem_vendor | sed 's/^0x//' | tr -d '\n')
rev=$(cat $sys_dir/revision | sed 's/^0x//')
info "intel nic"
echo "Ethernet: $ethx"
echo "Vendor: $ven"
echo "Device: $dev"
echo "Subsystem: $subsys"
echo "Revision: $rev"
compatible_ids="VEN_$ven&DEV_$dev&SUBSYS_$subsys&REV_$rev"
compatible_ids="$compatible_ids|VEN_$ven&DEV_$dev&SUBSYS_$subsys"
compatible_ids="$compatible_ids|VEN_$ven&DEV_$dev&REV_$rev"
compatible_ids="$compatible_ids|VEN_$ven&DEV_$dev"
while read -r min_ver ndis; do
if [ "$build_ver" -ge "$min_ver" ]; then
# 只支持 PE?
# 有 intel\Release_30.0.zip\PROXGB\Win32\NDIS68\WinPE\*.inf
# 没有 intel\Release_30.0.zip\PROXGB\Win32\NDIS68\*.inf
# find 只要 $drv/intel 存在返回码就是 0
# rg 无需 -E
# 非 WinPE 优先
if infs=$(find $drv/intel -ipath "*/Win$arch_intel/$ndis/*.inf" -exec rg -iwl "$compatible_ids" {} \; | grep . ||
find $drv/intel -ipath "*/Win$arch_intel/$ndis/WinPE/*.inf" -exec rg -iwl "$compatible_ids" {} \; | grep .); then
for inf in $infs; do
cp_drivers $inf
done
break
fi
fi
done < <(echo "$min_support_map" | tac) # 倒序
done
apk del unzip ripgrep
}
# aws nitro
# https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html
# https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html
@ -5853,6 +5981,8 @@ install_windows() {
info "mount boot.wim"
wimmountrw /os/boot.wim "$boot_index" /wim/
# 防止重复
copyed_infs=
cp_drivers() {
if [ "$1" = custom ]; then
shift
@ -5867,9 +5997,13 @@ install_windows() {
# -not -iname "*.pdb" \
# -not -iname "dpinst.exe" \
find $src -type f -iname "*.inf" "$@" | while read -r inf; do
parse_inf_and_cp_driever "$inf" "$dst" "$arch" false
done
# 这里需要在 while 里面变更 $copyed_infs因此不能用 find | while
while read -r inf; do
if ! is_list_has "$copyed_infs" "$inf"; then
parse_inf_and_cp_driever "$inf" "$dst" "$arch" false
copyed_infs=$(list_add "$copyed_infs" "$inf")
fi
done < <(find $src -type f -iname "*.inf" "$@")
}
# 添加驱动

View File

@ -3,6 +3,8 @@
# shellcheck disable=SC3001,SC3010
# reinstall.sh / trans.sh 共用此文件
# inf 是 utf-16-le 编码会有问题?要用 rg 或者 grep -a a.b.c.d ?
del_inf_comment() {
sed 's/;.*//'
}
@ -79,6 +81,16 @@ list_files_from_inf() {
# 0. 检测 inf 是否适合当前架构
# 目前没有对比版本号
##############################################
# 注意这种情况, NTamd64.6.0 为空,表示不支持 6.0
# [Manufacturer]
# %V_INTEL% = Intel, NTamd64.6.0, NTamd64.6.1.1
# [Intel.NTamd64.6.0]
# ; Empty section.
##############################################
# 例子1
# [Manufacturer]
# %Amazon% = AWSNVME, NTamd64, NTARM64
@ -163,6 +175,7 @@ list_files_from_inf() {
# 注意可能有空格和引号
if $in_section; then
local num dir
num=$(echo "$line" | awk -F= '{print $1}' | simply_inf_word)
dir=$(echo "$line" | awk -F, '{print $4}' | simply_inf_word)
# 每行一条记录
@ -276,3 +289,22 @@ parse_inf_and_cp_driever() {
fi
fi
}
get_sys_dir_for_eth() {
(
cd "$(readlink -f "/sys/class/net/$1")" || error_and_exit "Can't cd to $1"
while ! [ "$(pwd)" = / ]; do
# DRIVER=virtio-pci
# PCI_CLASS=20000 # 2 开头表示网络设备
# PCI_ID=1AF4:1041
# PCI_SUBSYS_ID=1AF4:1100
# PCI_SLOT_NAME=0000:03:00.0
if [ -f uevent ] && grep -q 'PCI_CLASS=2' uevent && grep -q 'PCI_ID' uevent; then
pwd
return
fi
cd ..
done
return 1
)
}