mirror of
https://github.com/bin456789/reinstall.git
synced 2025-06-08 05:19:57 +00:00
windows: 优化驱动选择
- 从注册表 Installation Type 判断是 Client 还是 Server,修复 2012 r2 评估版识别成 Client - 添加 virtio sha256 驱动 - 必要时才安装 GCP win7 nvme 驱动
This commit is contained in:
parent
2c15d1be98
commit
89f01de6b6
@ -400,7 +400,7 @@ bash reinstall.sh windows \
|
|||||||
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
||||||
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
||||||
- Azure ([MANA Network Adapter][azure-mana])
|
- Azure ([MANA Network Adapter][azure-mana])
|
||||||
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [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])
|
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2-sha256], [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-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
|
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||||
|
@ -400,7 +400,7 @@ bash reinstall.sh windows \
|
|||||||
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
||||||
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
||||||
- Azure ([MANA 网卡][azure-mana])
|
- Azure ([MANA 网卡][azure-mana])
|
||||||
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha256], [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])
|
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2-sha256], [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-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
|
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||||
|
158
trans.sh
158
trans.sh
@ -2789,7 +2789,9 @@ modify_windows() {
|
|||||||
image_state=IMAGE_STATE_COMPLETE
|
image_state=IMAGE_STATE_COMPLETE
|
||||||
if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then
|
if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then
|
||||||
cat -n $state_ini
|
cat -n $state_ini
|
||||||
image_state=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r')
|
if tmp=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r' | grep .); then
|
||||||
|
image_state=$tmp
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$image_state" = IMAGE_STATE_COMPLETE ]; then
|
if [ "$image_state" = IMAGE_STATE_COMPLETE ]; then
|
||||||
@ -5229,12 +5231,24 @@ is_list_has() {
|
|||||||
echo "$list" | grep -qFx "$item"
|
echo "$list" | grep -qFx "$item"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_installation_type_from_windows_drive() {
|
||||||
|
os_dir=$1
|
||||||
|
|
||||||
|
apk add hivex
|
||||||
|
software_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE)
|
||||||
|
hivexsh "$software_hive" <<EOF
|
||||||
|
cd \Microsoft\Windows NT\CurrentVersion
|
||||||
|
lsval InstallationType
|
||||||
|
EOF
|
||||||
|
apk del hivex
|
||||||
|
}
|
||||||
|
|
||||||
install_windows() {
|
install_windows() {
|
||||||
get_wim_prop() {
|
get_wim_prop() {
|
||||||
wim=$1
|
wim=$1
|
||||||
property=$2
|
property=$2
|
||||||
|
|
||||||
wiminfo "$wim" | grep -i "^$property:" | cut -d: -f2- | xargs
|
wiminfo "$wim" | grep -i "^$property:" | cut -d: -f2- | trim
|
||||||
}
|
}
|
||||||
|
|
||||||
get_image_prop() {
|
get_image_prop() {
|
||||||
@ -5242,7 +5256,7 @@ install_windows() {
|
|||||||
index=$2
|
index=$2
|
||||||
property=$3
|
property=$3
|
||||||
|
|
||||||
wiminfo "$wim" "$index" | grep -i "^$property:" | cut -d: -f2- | xargs
|
wiminfo "$wim" "$index" | grep -i "^$property:" | cut -d: -f2- | trim
|
||||||
}
|
}
|
||||||
|
|
||||||
info "Process windows iso"
|
info "Process windows iso"
|
||||||
@ -5283,7 +5297,7 @@ install_windows() {
|
|||||||
|
|
||||||
# 匹配映像版本
|
# 匹配映像版本
|
||||||
# 需要整行匹配,因为要区分 Windows 10 Pro 和 Windows 10 Pro for Workstations
|
# 需要整行匹配,因为要区分 Windows 10 Pro 和 Windows 10 Pro for Workstations
|
||||||
image_count=$(wiminfo $iso_install_wim | grep "^Image Count:" | cut -d: -f2 | xargs)
|
image_count=$(wiminfo $iso_install_wim | grep "^Image Count:" | cut -d: -f2 | trim)
|
||||||
all_image_names=$(wiminfo $iso_install_wim | grep ^Name: | sed 's/^Name: *//')
|
all_image_names=$(wiminfo $iso_install_wim | grep ^Name: | sed 's/^Name: *//')
|
||||||
info "Images Count: $image_count"
|
info "Images Count: $image_count"
|
||||||
echo "$all_image_names"
|
echo "$all_image_names"
|
||||||
@ -5326,6 +5340,7 @@ install_windows() {
|
|||||||
# 多会话的信息来自注册表,因为没有官方 iso
|
# 多会话的信息来自注册表,因为没有官方 iso
|
||||||
|
|
||||||
# Installation Type:
|
# Installation Type:
|
||||||
|
# https://github.com/search?q=InstallationType+Client+Embedded+Server+Core&type=code
|
||||||
# - Client (普通 windows)
|
# - Client (普通 windows)
|
||||||
# - Server (windows server 带桌面体验)
|
# - Server (windows server 带桌面体验)
|
||||||
# - Server Core (windows server 不带桌面体验)
|
# - Server Core (windows server 不带桌面体验)
|
||||||
@ -5343,58 +5358,63 @@ install_windows() {
|
|||||||
|
|
||||||
# Product Suite:
|
# Product Suite:
|
||||||
# https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/exinit/productsuite.htm
|
# https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/exinit/productsuite.htm
|
||||||
# - Terminal Server (普通 windows)
|
# - Terminal Server (普通 windows)
|
||||||
# - Enterprise (windows server 带桌面体验)
|
# - Enterprise (windows server 2025 带桌面体验)
|
||||||
# - Enterprise (windows server 不带桌面体验)
|
# - Enterprise (windows server 2025 不带桌面体验)
|
||||||
# - Terminal Server (WES7 / Thin PC)
|
# - Terminal Server (windows server 2012 R2 评估板 带桌面体验,注册表也是这个值)
|
||||||
# - ? (windows 10/11 enterprise 多会话)
|
# - Terminal Server (windows server 2022 R2 评估板 不带桌面体验,注册表也是这个值)
|
||||||
|
# - Terminal Server (WES7 / Thin PC)
|
||||||
|
# - ? (windows 10/11 enterprise 多会话)
|
||||||
|
|
||||||
# 用内核版本号筛选驱动
|
# 用内核版本号筛选驱动
|
||||||
# 使得可以安装 Hyper-V Server / Azure Stack HCI 等 Windows Server 变种
|
# 使得可以安装 Hyper-V Server / Azure Stack HCI 等 Windows Server 变种
|
||||||
nt_ver=$(get_selected_image_prop "Major Version").$(get_selected_image_prop "Minor Version")
|
# 7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso wim 没有 Installation Type
|
||||||
build_ver=$(get_selected_image_prop "Build")
|
# 因此改成从注册表获取
|
||||||
product_suite=$(get_selected_image_prop "Product Suite")
|
if false; then
|
||||||
|
nt_ver=$(get_selected_image_prop "Major Version").$(get_selected_image_prop "Minor Version")
|
||||||
case "$product_suite" in
|
build_ver=$(get_selected_image_prop "Build")
|
||||||
'Terminal Server')
|
installation_type=$(get_selected_image_prop "Installation Type")
|
||||||
windows_type=client
|
fi
|
||||||
product_ver=$(get_client_name_by_build_ver "$build_ver")
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
windows_type=server
|
|
||||||
product_ver=$(get_server_name_by_build_ver "$build_ver")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# 挂载 install.wim,检查
|
# 挂载 install.wim,检查
|
||||||
# 1. 是否自带 sac 组件
|
# 1. 是否自带 sac 组件
|
||||||
# 2. 是否自带 nvme 驱动
|
# 2. 是否自带 nvme 驱动
|
||||||
# 3. 是否支持 sha256
|
# 3. 是否支持 sha256
|
||||||
|
# 4. Installation Type
|
||||||
wimmount "$iso_install_wim" "$image_index" /wim/
|
wimmount "$iso_install_wim" "$image_index" /wim/
|
||||||
|
ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe)
|
||||||
|
get_windows_version_from_dll "$ntoskrnl_exe"
|
||||||
|
installation_type=$(get_installation_type_from_windows_drive /wim)
|
||||||
{
|
{
|
||||||
find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false
|
find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false
|
||||||
find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false
|
find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false
|
||||||
} >/dev/null 2>&1
|
} >/dev/null 2>&1
|
||||||
|
|
||||||
support_sha256=false
|
|
||||||
if is_nt_ver_ge 6.2; then
|
|
||||||
support_sha256=true
|
|
||||||
else
|
|
||||||
# https://www.hummingheads.co.jp/press/info-certificates.html
|
|
||||||
# https://support.microsoft.com/kb/KB3033929
|
|
||||||
# https://support.microsoft.com/kb/KB4474419
|
|
||||||
# Windows Vista SP2 ldr_escrow 6.0.6003 + KB4474419
|
|
||||||
# Windows 7 SP1 6.1.7601 + KB3033929
|
|
||||||
ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe)
|
|
||||||
get_windows_version_from_dll "$ntoskrnl_exe"
|
|
||||||
if { [ "$nt_ver" = 6.0 ] && [ "$build_ver" -ge 6003 ] && [ "$rev_ver" -ge 20555 ]; } ||
|
|
||||||
{ [ "$nt_ver" = 6.1 ] && [ "$build_ver" -ge 7601 ] && [ "$rev_ver" -ge 18741 ]; }; then
|
|
||||||
support_sha256=true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
wimunmount /wim/
|
wimunmount /wim/
|
||||||
|
|
||||||
|
# https://www.hummingheads.co.jp/press/info-certificates.html
|
||||||
|
# https://support.microsoft.com/kb/KB3033929
|
||||||
|
# https://support.microsoft.com/kb/KB4474419
|
||||||
|
# Windows Vista SP2 ldr_escrow 6.0.6003 + KB4474419
|
||||||
|
# Windows 7 SP1 6.1.7601 + KB3033929
|
||||||
|
support_sha256=false
|
||||||
|
if is_nt_ver_ge 6.2 ||
|
||||||
|
{ [ "$nt_ver" = 6.1 ] && [ "$build_ver" -ge 7601 ] && [ "$rev_ver" -ge 18741 ]; } ||
|
||||||
|
{ [ "$nt_ver" = 6.0 ] && [ "$build_ver" -ge 6003 ] && [ "$rev_ver" -ge 20555 ]; }; then
|
||||||
|
support_sha256=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$installation_type" in
|
||||||
|
Client | Embedded)
|
||||||
|
windows_type=client
|
||||||
|
product_ver=$(get_client_name_by_build_ver "$build_ver")
|
||||||
|
;;
|
||||||
|
Server | 'Server Core')
|
||||||
|
windows_type=server
|
||||||
|
product_ver=$(get_server_name_by_build_ver "$build_ver")
|
||||||
|
;;
|
||||||
|
*) error_and_exit "Unknown Installation Type: $installation_type" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
info "Selected image info"
|
info "Selected image info"
|
||||||
echo "Image Name: $image_name"
|
echo "Image Name: $image_name"
|
||||||
echo "Product Version: $product_ver"
|
echo "Product Version: $product_ver"
|
||||||
@ -5499,6 +5519,10 @@ install_windows() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# win7 drvload 可以加载 sha256 签名的驱动
|
||||||
|
# 但系统安装完重启报错 windows cannot verify the digital signature for this file
|
||||||
|
# 需要按 F8 禁用驱动签名
|
||||||
|
|
||||||
add_drivers() {
|
add_drivers() {
|
||||||
info "Add drivers"
|
info "Add drivers"
|
||||||
|
|
||||||
@ -5836,21 +5860,46 @@ EOF
|
|||||||
esac
|
esac
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://fedorapeople.org/groups/virt/virtio-win/repo/stable/
|
# win7-drivers 分支 win7 文件夹只有一次提交,也就是 173 全家桶
|
||||||
# 171-1 是稳定版
|
# 1. 2020.1.24 https://github.com/virtio-win/virtio-win-pkg-scripts/tree/win7-drivers/data/old-drivers/Win7
|
||||||
# 173-9 不是稳定版?
|
|
||||||
# 185 ~ 187 win7 vioscsi 是 sha256 签名
|
# master 分支 win7 文件夹有 3 次提交,从古到今
|
||||||
# 189 ~ 215 win7 vultr 气球驱动死机
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/commits/master/data/old-drivers/Win7
|
||||||
# 217 ~ 271 win7 甲骨文 vioscsi 用不了,即使是红帽的 virtio-win-1.9.45 也用不了
|
# 1. 2020/6/4 sha256,176 全家桶,相当于没发布的 176 iso
|
||||||
# 217 ~ 271 2k12 证书有问题
|
# 2. 2020/8/10 将部分文件降到 17400,相当于 189~215 iso
|
||||||
|
# 3. 2022/4/14 将部分文件降级,相当于 217~最新版 iso
|
||||||
|
|
||||||
# 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动
|
# 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动
|
||||||
|
|
||||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
# 2k12
|
||||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
||||||
|
# 217 ~ 271 2k12 证书有问题,红帽的 virtio-win-1.9.45 没问题
|
||||||
|
|
||||||
|
# win7
|
||||||
|
# https://fedorapeople.org/groups/virt/virtio-win/repo/stable/
|
||||||
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
||||||
|
# 171-1 sha1 稳定版
|
||||||
|
# 173-9 sha1 对应上面的 win7-drivers 分支,最后一次编译 win7 + sha1,但不是稳定版?
|
||||||
|
# 176 sha256 对应上面的 master-1 最后一次编译 win7,从这次开始是 sha256,此次不提供 iso,编译的文件在之后的 iso 可以找到
|
||||||
|
# 185 ~ 187 sha256 正常工作,win7 文件来自 176
|
||||||
|
# 189 ~ 215 sha1 对应上面的 master-2 气球版本 17400,vultr 死机
|
||||||
|
# 217 ~ 271 sha1 对应上面的 master-3 甲骨文 vioscsi 因硬件 ID 不同用不了,红帽的 virtio-win-1.9.45 也是
|
||||||
|
|
||||||
|
# 甲骨文 vioscsi 硬件 ID 是 PCI\VEN_1AF4&DEV_1004&SUBSYS_0008108E&REV_00
|
||||||
|
# SUBSYS 的厂商 ID 是甲骨文
|
||||||
|
|
||||||
|
# virtio-win-0.1.173-9
|
||||||
|
# %VirtioScsi.DeviceDesc% = scsi_inst, PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00, PCI\VEN_1AF4&DEV_1004
|
||||||
|
# %VirtioScsi.DeviceDesc% = scsi_inst, PCI\VEN_1AF4&DEV_1048&SUBSYS_11001AF4&REV_01, PCI\VEN_1AF4&DEV_1048
|
||||||
|
|
||||||
|
# stable-virtio
|
||||||
|
# %RHELScsi.DeviceDesc% = rhelscsi_inst, PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00
|
||||||
|
# %RHELScsi.DeviceDesc% = rhelscsi_inst, PCI\VEN_1AF4&DEV_1048&SUBSYS_11001AF4&REV_01
|
||||||
|
|
||||||
case "$nt_ver" in
|
case "$nt_ver" in
|
||||||
# 最新版里面的 win2008 win7 是 sha1 签名的,但是甲骨文 vioscsi 用不了
|
6.0 | 6.1) $support_sha256 &&
|
||||||
6.0 | 6.1) dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2
|
dir=archive-virtio/virtio-win-0.1.187-1 ||
|
||||||
|
dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2
|
||||||
6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-2 ;; # w8|w8.1|2k12|2k12R2
|
6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-2 ;; # w8|w8.1|2k12|2k12R2
|
||||||
*) dir=stable-virtio ;;
|
*) dir=stable-virtio ;;
|
||||||
esac
|
esac
|
||||||
@ -6036,6 +6085,10 @@ EOF
|
|||||||
add_driver_gcp_virtio_win6_1_sha1_x64() {
|
add_driver_gcp_virtio_win6_1_sha1_x64() {
|
||||||
info "Add drivers: GCP virtio win6.1 sha1 x64"
|
info "Add drivers: GCP virtio win6.1 sha1 x64"
|
||||||
|
|
||||||
|
# 用到 nvme 时才下载 nvme 驱动
|
||||||
|
# 因为 win7 可以通过更新获得 nvme 驱动
|
||||||
|
# 而且谷歌推荐使用微软 nvme 驱动
|
||||||
|
# (google-compute-engine-driver-nvme 2.0.0 更新内容是删除谷歌 nvme 驱动)
|
||||||
mkdir -p $drv/gce/win6.1sha1
|
mkdir -p $drv/gce/win6.1sha1
|
||||||
for file in \
|
for file in \
|
||||||
WdfCoInstaller01009.dll WdfCoInstaller01011.dll \
|
WdfCoInstaller01009.dll WdfCoInstaller01011.dll \
|
||||||
@ -6435,7 +6488,8 @@ sync_time() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
hwclock -w
|
# 重启时 alpine 会自动写入到硬件时钟,因此这里跳过
|
||||||
|
# hwclock -w
|
||||||
}
|
}
|
||||||
|
|
||||||
is_ubuntu_lts() {
|
is_ubuntu_lts() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user