windows: 添加自定义驱动

This commit is contained in:
bin456789 2025-02-15 00:25:38 +08:00
parent 3d11c791a7
commit d0342c3ebf
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
6 changed files with 187 additions and 84 deletions

View File

@ -32,22 +32,22 @@ The original system can be any system listed in the table.
The system requirements for the target system are as follows:
| Target System | Version | Memory | Disk |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------------- |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | -----------------|
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB |
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://canonical-subiquity.readthedocs-hosted.com/en/latest/_static/favicon.png" /> Ubuntu | 16.04 - 24.04, 24.10 | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://canonical-subiquity.readthedocs-hosted.com/en/latest/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL &nbsp;<img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux &nbsp;<img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky &nbsp;<img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS | 9, 10 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 40, 41 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 - 24.03, 24.09 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 512 MB | 5 GB |
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | Rolling | 512 MB | 5 GB |
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | Rolling | 512 MB | 5 GB |
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Any | 512 MB | Depending on the image |
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (DD) | Any | 512 MB | Depends on image |
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
| <img width="16" height="16" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
@ -259,8 +259,7 @@ bash reinstall.sh netboot.xyz
> [!CAUTION]
> The ISO repository currently prohibits direct link downloads, so this method is no longer effective.
- Typically, Windows releases new official ISOs every month, which integrate the latest system patches, avoiding the need to download a bunch of updates right after installation.
- The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects monthly released ISOs, ensuring that the ISOs found by the script are the official latest versions.
- The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs.
- Systems marked with \* do not support automatic ISO searching.
```bash
@ -323,39 +322,56 @@ zh-tw
```bash
bash reinstall.sh windows \
--image-name 'Windows 11 Enterprise LTSC 2024' \
--iso 'https://drive.massgrave.dev/zh-cn_windows_11_enterprise_ltsc_2024_x64_dvd_cff9cd2d.iso'
--iso 'https://go.microsoft.com/fwlink/?linkid=2289029'
```
<details>
<summary>The following website provides ISO links.</summary>
- <https://massgrave.dev/genuine-installation-media> (Recommended, iso sourced from official channels, updated monthly, includes the latest patches)
- <https://www.microsoft.com/software-download/windows10> (Need to open it with a non-Windows User-Agent)
- <https://www.microsoft.com/software-download/windows11>
- <https://www.microsoft.com/software-download/windows11arm64>
- <https://www.microsoft.com/software-download/windowsinsiderpreviewiso> (Preview)
- <https://www.microsoft.com/software-download/windowsinsiderpreviewserver> (Preview)
- <https://www.microsoft.com/evalcenter/download-windows-10-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-iot-enterprise-ltsc-eval>
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
- <https://www.microsoft.com/evalcenter/download-windows-server-2016>
- <https://www.microsoft.com/evalcenter/download-windows-server-2019>
- <https://www.microsoft.com/evalcenter/download-windows-server-2022>
- <https://www.microsoft.com/evalcenter/download-windows-server-2025>
- General
- <https://msdl.gravesoft.dev>
- <https://massgrave.dev/genuine-installation-media>
- <https://www.microsoft.com/software-download/windows10> (Need to open it with a non-Windows User-Agent)
- <https://www.microsoft.com/software-download/windows11>
- <https://www.microsoft.com/software-download/windows11arm64>
- Evaluation
- <https://www.microsoft.com/evalcenter/download-windows-10-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-iot-enterprise-ltsc-eval>
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
- <https://www.microsoft.com/evalcenter/download-windows-server-2016>
- <https://www.microsoft.com/evalcenter/download-windows-server-2019>
- <https://www.microsoft.com/evalcenter/download-windows-server-2022>
- <https://www.microsoft.com/evalcenter/download-windows-server-2025>
- Insider Preview
- <https://www.microsoft.com/software-download/windowsinsiderpreviewiso>
- <https://www.microsoft.com/software-download/windowsinsiderpreviewserver>
</details>
#### Optional parameters
- `--password PASSWORD` Set Password
- `--allow-ping` Allow ping responses
- `--allow-ping` Configures the Windows firewall to allow ping requests
- `--rdp-port PORT` Change RDP port
- `--ssh-port PORT` Change SSH port (for log observation during installation)
- `--web-port PORT` Change Web port (for log observation during installation)
- `--add-driver-dir DIR` Adds an additional driver folder, specifying the folder where the .inf file is located.
- The driver must be downloaded locally first.
- This parameter can be set multiple times to add different driver folders.
- The script will copy the entire folder, so no other files should be placed inside the folder.
- `--hold 2` Allow SSH connections for modifying the disk content before rebooting into the official Windows installation program, with the disk mounted at `/os`.
#### The script will automatic download and install the following drivers 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/update-red-hat-virtio-drivers-of-windows-instances))
- 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 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))
#### How to Specify the Image Name `--image-name`
Typically, an ISO will contain multiple system versions, such as Home Edition and Professional Edition. The image name `--image-name` is used to specify the version to be installed, and it is case-insensitive when entered.
@ -377,15 +393,6 @@ Open File menu > Open Image File, select the iso to be installed to get the imag
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
#### The script will install the following drivers as needed
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances))
- 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 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))
> [!WARNING]
> Vista (Server 2008) and 32-bit systems may lack drivers.

View File

@ -36,13 +36,13 @@
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB |
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
| <img width="16" height="16" src="https://canonical-subiquity.readthedocs-hosted.com/en/latest/_static/favicon.png" /> Ubuntu | 16.04 - 24.04, 24.10 | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://canonical-subiquity.readthedocs-hosted.com/en/latest/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 512 MB \* | 2 GB |
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL &nbsp;<img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux &nbsp;<img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky &nbsp;<img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS | 9, 10 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 40, 41 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 - 24.03, 24.09 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 512 MB | 5 GB |
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
@ -259,8 +259,7 @@ bash reinstall.sh netboot.xyz
> [!CAUTION]
> 目前该 ISO 仓库禁止了直链下载,因此该方法已失效
- 通常情况下 Windows 每个月都会发布新的官方 ISO集成了最新的系统补丁避免了刚安装好系统就要下载一堆补丁
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO该网站收录了每月发布的 ISO因此脚本查找到的 ISO 都是官方最新版
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO该网站专门提供官方 ISO 下载
- 上面带 \* 的系统不支持自动查找 ISO
```bash
@ -323,39 +322,56 @@ zh-tw
```bash
bash reinstall.sh windows \
--image-name 'Windows 11 Enterprise LTSC 2024' \
--iso 'https://drive.massgrave.dev/zh-cn_windows_11_enterprise_ltsc_2024_x64_dvd_cff9cd2d.iso'
--iso 'https://go.microsoft.com/fwlink/?linkid=2289029'
```
<details>
<summary>以下网站可找到 ISO 链接</summary>
- <https://massgrave.dev/genuine-installation-media> (推荐iso 来自官方,每月更新,包含最新补丁)
- <https://www.microsoft.com/software-download/windows10> (需用非 Windows User-Agent 打开)
- <https://www.microsoft.com/software-download/windows11>
- <https://www.microsoft.com/software-download/windows11arm64>
- <https://www.microsoft.com/software-download/windowsinsiderpreviewiso> (预览版)
- <https://www.microsoft.com/software-download/windowsinsiderpreviewserver> (预览版)
- <https://www.microsoft.com/evalcenter/download-windows-10-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-iot-enterprise-ltsc-eval>
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
- <https://www.microsoft.com/evalcenter/download-windows-server-2016>
- <https://www.microsoft.com/evalcenter/download-windows-server-2019>
- <https://www.microsoft.com/evalcenter/download-windows-server-2022>
- <https://www.microsoft.com/evalcenter/download-windows-server-2025>
- 正式版
- <https://msdl.gravesoft.dev>
- <https://massgrave.dev/genuine-installation-media>
- <https://www.microsoft.com/software-download/windows10> (需用非 Windows User-Agent 打开)
- <https://www.microsoft.com/software-download/windows11>
- <https://www.microsoft.com/software-download/windows11arm64>
- 评估版
- <https://www.microsoft.com/evalcenter/download-windows-10-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-enterprise>
- <https://www.microsoft.com/evalcenter/download-windows-11-iot-enterprise-ltsc-eval>
- <https://www.microsoft.com/evalcenter/download-windows-server-2012-r2>
- <https://www.microsoft.com/evalcenter/download-windows-server-2016>
- <https://www.microsoft.com/evalcenter/download-windows-server-2019>
- <https://www.microsoft.com/evalcenter/download-windows-server-2022>
- <https://www.microsoft.com/evalcenter/download-windows-server-2025>
- Insider 预览版
- <https://www.microsoft.com/software-download/windowsinsiderpreviewiso>
- <https://www.microsoft.com/software-download/windowsinsiderpreviewserver>
</details>
#### 可选参数
- `--password PASSWORD` 设置密码
- `--allow-ping` 允许被 Ping
- `--allow-ping` 设置 Windows 防火墙允许被 Ping
- `--rdp-port PORT` 更改 RDP 端口
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
- `--add-driver-dir DIR` 添加额外驱动文件夹,填写 .inf 所在的文件夹
- 需先下载驱动到本地
- 可多次设置该参数以添加不同的驱动文件夹
- 脚本将复制整个文件夹,因此文件夹内不要放置其他文件
- `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os`
#### 脚本会自动按需下载安装以下驱动,无需手动添加
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances))
- 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))
#### 如何填写映像名称 `--image-name`
通常一个 ISO 会包含多个系统版本,例如家庭版、专业版。映像名称 `--image-name` 就是用来指定要安装的版本,填写时不区分大小写
@ -377,15 +393,6 @@ Windows Server 2025 SERVERDATACENTER
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
#### 脚本会按需安装以下驱动
- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)、[阿里云](https://www.alibabacloud.com/help/ecs/user-guide/update-red-hat-virtio-drivers-of-windows-instances))
- 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))
> [!WARNING]
> Vista (Server 2008) 和 32 位系统可能会缺少驱动

View File

@ -3330,8 +3330,13 @@ EOF
chmod a+x \$sysroot/etc/local.d/trans.start
ln -s /etc/init.d/local \$sysroot/etc/runlevels/default/
# 配置文件夹
cp -r /configs \$sysroot/configs
# 配置 + 自定义驱动
for dir in /configs /custom_drivers; do
if [ -d \$dir ]; then
cp -r \$dir \$sysroot/
rm -rf \$dir
fi
done
EOF
# 判断云镜像 debain 能否用云内核
@ -3389,6 +3394,19 @@ This script is outdated, please download reinstall.sh again.
mod_initrd_$nextos_distro
fi
# 添加自定义 windows 驱动
if [ "$distro" = windows ]; then
mkdir -p $initrd_dir/custom_drivers
i=0
while IFS= read -r dir; do
if [ -d "$dir" ]; then
((i += 1))
info "add custom driver: $dir"
cp -r "$dir" "$initrd_dir/custom_drivers/$i"
fi
done < <(echo "$custom_driver_dirs")
fi
# alpine live 不精简 initrd
# 因为不知道用户想干什么,可能会用到精简的文件
if is_virt && ! is_alpine_live; then
@ -3406,6 +3424,8 @@ This script is outdated, please download reinstall.sh again.
}
remove_useless_initrd_files() {
info "slim initrd"
# 显示精简前的大小
du -sh .
@ -3510,6 +3530,7 @@ fi
long_opts=
for o in ci installer debug minimal allow-ping force-cn \
add-driver-dir: \
hold: sleep: \
iso: \
image-name: \
@ -3602,6 +3623,28 @@ while true; do
web_port=$2
shift 2
;;
--add-driver-dir)
# 指定 dir 而不是指定 inf
# 防止用户将 inf 放在 / 而复制整个 /
# 路径转换
if is_in_windows; then
# 输入的路径是 / 开头也没问题
dir="$(cygpath -u "$2")"
else
dir=$2
fi
# 防止重复添加
if ! grep -Fqx "$dir" <<<"$custom_driver_dirs"; then
# shellcheck disable=SC2010
{ [ -d "$dir" ] && ls "$dir" | grep -Eiq '\.inf$'; } || error_and_exit "Invalid Driver Directory: $2"
# 一行一个驱动文件夹
custom_driver_dirs+="$dir
"
fi
shift 2
;;
--force-old-windows-setup)
force_old_windows_setup=$2
shift 2

View File

@ -4852,7 +4852,6 @@ install_windows() {
drv=/os/drivers
mkdir -p "$drv" # 驱动下载临时文件夹
mkdir -p "/wim/drivers" # boot.wim 驱动文件夹
# 这里有坑
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
@ -4912,6 +4911,9 @@ install_windows() {
add_driver_gcp
;;
esac
# 自定义驱动
add_driver_custom
}
# aws nitro
@ -5273,6 +5275,23 @@ install_windows() {
cp_drivers $drv/vmd
}
# 脚本自动检测驱动可能有问题
# 假设是 win7 时代的网卡,官网没有 win10 驱动,系统也不自带
# 但实际上 win10 可以用 win7 的驱动
# 这种情况即使脚本自动下载 win10 的驱动包,也不会包含这个驱动
# 应该下载 win7 的驱动
# 因此只能交给用户自己添加驱动
add_driver_custom() {
for dir in /custom_drivers/*; do
if [ -d "$dir" ]; then
info "Add custom drivers: $dir"
cp_drivers custom "$dir"
# 复制后不删除,因为脚本可能再次运行
fi
done
}
# 修改应答文件
download $confhome/windows.xml /tmp/autounattend.xml
locale=$(get_selected_image_prop 'Default Language')
@ -5327,6 +5346,14 @@ install_windows() {
wimmountrw /os/boot.wim "$boot_index" /wim/
cp_drivers() {
if [ "$1" = custom ]; then
shift
dst="/wim/custom_drivers/$(basename "$1")"
else
dst=/wim/drivers
fi
mkdir -p "$dst"
src=$1
shift
@ -5335,7 +5362,7 @@ install_windows() {
-not -iname "*.pdb" \
-not -iname "dpinst.exe" \
"$@" \
-exec cp -rfv {} /wim/drivers \;
-exec cp -rfv {} "$dst" \;
}
# 添加驱动

View File

@ -23,10 +23,15 @@ call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 2>nul
rem 安装 SCSI 驱动
for %%F in ("X:\drivers\*.inf") do (
rem 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格
find /i "SCSIAdapter" "%%~F" >nul
if not errorlevel 1 (
drvload "%%~F"
call :drvload_if_scsi "%%~F"
)
rem 安装自定义 SCSI 驱动
rem 可以用 forfiles /p X:\custom_drivers /m *.inf /c "cmd /c echo @path"
rem 不可以用 for %%F in ("X:\custom_drivers\*\*.inf")
if exist X:\custom_drivers\ (
for /f "delims=" %%F in ('dir /s /b "X:\custom_drivers\*.inf"') do (
call :drvload_if_scsi "%%~F"
)
)
@ -154,6 +159,7 @@ set EnableUnattended=1
rem 运行 ramdisk X:\setup.exe 的话
rem vista 会找不到安装源
rem server 23h2 会无法运行
rem 使用 /installfrom 可以解决?
if "%ForceOldSetup%"=="1" (
set setup=Y:\sources\setup.exe
) else (
@ -214,3 +220,11 @@ exit /b
:createPageFileOnZ
wpeutil CreatePageFile /path=Z:\pagefile.sys /size=512
exit /b
:drvload_if_scsi
rem 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格
find /i "SCSIAdapter" "%~1" >nul
if not errorlevel 1 (
drvload "%~1"
)
exit /b

View File

@ -49,9 +49,14 @@
<settings pass="offlineServicing">
<component name="Microsoft-Windows-PnpCustomizationsNonWinPE" processorArchitecture="%arch%" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DriverPaths>
<!-- 目录为空不会报错 -->
<!-- 驱动可以放在子目录 -->
<PathAndCredentials wcm:action="add" wcm:keyValue="1">
<Path>X:\drivers</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="2">
<Path>X:\custom_drivers</Path>
</PathAndCredentials>
</DriverPaths>
</component>
</settings>