mirror of
https://github.com/bin456789/reinstall.git
synced 2025-07-12 22:20:01 +00:00
Compare commits
6 Commits
275e1812dd
...
e1ae933250
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e1ae933250 | ||
![]() |
d0342c3ebf | ||
![]() |
3d11c791a7 | ||
![]() |
e57a15118b | ||
![]() |
024c8841e2 | ||
![]() |
f84f40f869 |
99
README.en.md
99
README.en.md
@ -31,25 +31,25 @@ 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://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 <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <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://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 (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 |
|
||||
| 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 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 <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <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 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 | 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 |
|
||||
|
||||
\* Indicates installation using cloud images, not traditional network installation.
|
||||
|
||||
@ -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
|
||||
|
||||

|
||||
|
||||
#### 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.
|
||||
|
||||
|
65
README.md
65
README.md
@ -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 <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <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
|
||||
|
||||

|
||||
|
||||
#### 脚本会按需安装以下驱动
|
||||
|
||||
- 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 位系统可能会缺少驱动
|
||||
|
||||
|
@ -2,6 +2,9 @@
|
||||
# shellcheck shell=dash
|
||||
# alpine / debian initrd 共用此脚本
|
||||
|
||||
# accept_ra 接收 RA + 自动配置网关
|
||||
# autoconf 自动配置地址,依赖 accept_ra
|
||||
|
||||
mac_addr=$1
|
||||
ipv4_addr=$2
|
||||
ipv4_gateway=$3
|
||||
@ -221,12 +224,12 @@ test_by_nc() {
|
||||
"$dst" 443
|
||||
}
|
||||
|
||||
is_debian() {
|
||||
[ -f /etc/lsb-release ] && grep -iq Debian /etc/lsb-release
|
||||
is_debian_kali() {
|
||||
[ -f /etc/lsb-release ] && grep -Eiq 'Debian|Kali' /etc/lsb-release
|
||||
}
|
||||
|
||||
test_connect() {
|
||||
if is_debian; then
|
||||
if is_debian_kali; then
|
||||
test_by_wget "$1" "$2"
|
||||
else
|
||||
test_by_nc "$1" "$2"
|
||||
@ -256,12 +259,16 @@ flush_ipv4_config() {
|
||||
ip -4 route flush dev "$ethx"
|
||||
}
|
||||
|
||||
should_disable_accept_ra=false
|
||||
should_disable_autoconf=false
|
||||
|
||||
flush_ipv6_config() {
|
||||
# 是否临时禁用 ra / slaac
|
||||
if [ "$1" = true ]; then
|
||||
if $should_disable_accept_ra; then
|
||||
echo 0 >"/proc/sys/net/ipv6/conf/$ethx/accept_ra"
|
||||
fi
|
||||
if $should_disable_autoconf; then
|
||||
echo 0 >"/proc/sys/net/ipv6/conf/$ethx/autoconf"
|
||||
fi
|
||||
|
||||
ip -6 addr flush scope global dev "$ethx"
|
||||
ip -6 route flush dev "$ethx"
|
||||
}
|
||||
@ -329,7 +336,7 @@ else
|
||||
dhcpcd)
|
||||
# https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/dhcpcd/dhcpcd.pre-install
|
||||
grep -q dhcpcd /etc/group || addgroup -S dhcpcd
|
||||
grep -q dhcpcd /etc/passwd || adduser -S -D \
|
||||
grep -q dhcpcd /etc/passwd || adduser -S -D -H \
|
||||
-h /var/lib/dhcpcd \
|
||||
-s /sbin/nologin \
|
||||
-G dhcpcd \
|
||||
@ -365,22 +372,29 @@ done
|
||||
# 由于还没设置静态ip,所以有条目表示有动态地址
|
||||
is_have_ipv4_addr && dhcpv4=true || dhcpv4=false
|
||||
is_have_ipv6_addr && dhcpv6_or_slaac=true || dhcpv6_or_slaac=false
|
||||
should_disable_ra_slaac=false
|
||||
if is_have_ipv6_gateway; then
|
||||
ra_has_gateway=true
|
||||
ipv6_gateway_from_ra=$(get_ipv6_gateway)
|
||||
else
|
||||
ra_has_gateway=false
|
||||
fi
|
||||
|
||||
# 如果自动获取的 IPv4 地址不是重装前的,则使用之前的
|
||||
# 如果自动获取的 IP 不是重装前的,则改成静态,使用之前的 IP
|
||||
# 只比较 IP,不比较掩码/网关,因为
|
||||
# 1. 假设掩码/网关导致无法上网,后面也会检测到并改成静态
|
||||
# 2. openSUSE wicked dhcpv6 是 64 位掩码,aws lightsail 模板上的也是,而其它 dhcpv6 软件都是 128 位掩码
|
||||
if $dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] &&
|
||||
! [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ]; then
|
||||
echo "IPv4 address auto obtained is different from old system."
|
||||
! [ "$(echo "$ipv4_addr" | cut -d/ -f1)" = "$(get_first_ipv4_addr | cut -d/ -f1)" ]; then
|
||||
echo "IPv4 address obtained from DHCP is different from old system."
|
||||
dhcpv4=false
|
||||
flush_ipv4_config
|
||||
fi
|
||||
|
||||
# 如果自动获取的 IPv6 地址不是重装前的,则使用之前的
|
||||
if $dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
|
||||
! [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ]; then
|
||||
echo "IPv6 address auto obtained is different from old system."
|
||||
! [ "$(echo "$ipv6_addr" | cut -d/ -f1)" = "$(get_first_ipv6_addr | cut -d/ -f1)" ]; then
|
||||
echo "IPv6 address obtained from SLAAC/DHCPv6 is different from old system."
|
||||
dhcpv6_or_slaac=false
|
||||
should_disable_ra_slaac=true
|
||||
should_disable_accept_ra=true
|
||||
should_disable_autoconf=true
|
||||
flush_ipv6_config
|
||||
fi
|
||||
|
||||
@ -393,39 +407,47 @@ ipv4_has_internet=false
|
||||
ipv6_has_internet=false
|
||||
test_internet
|
||||
|
||||
# 如果 IPv4 无法上网,并且自动获取的网关不是重装前的网关,则改成静态
|
||||
# 如果无法上网,并且自动获取的 掩码/网关 不是重装前的,则改成静态
|
||||
# ip_addr 包括 IP/掩码,所以可以用来判断掩码是否不同
|
||||
# IP 不同的情况在前面已经改成静态了
|
||||
if ! $ipv4_has_internet &&
|
||||
$dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] &&
|
||||
! [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; then
|
||||
echo "IPv4 gateway auto obtained is different from old system."
|
||||
! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] || [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then
|
||||
echo "IPv4 netmask/gateway obtained from DHCP is different from old system."
|
||||
dhcpv4=false
|
||||
flush_ipv4_config
|
||||
add_missing_ipv4_config
|
||||
test_internet
|
||||
fi
|
||||
|
||||
# 如果 IPv6 无法上网,并且自动获取的网关不是重装前的网关,则改成静态
|
||||
if ! $ipv6_has_internet &&
|
||||
$dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
|
||||
! [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; then
|
||||
echo "IPv6 gateway auto obtained is different from old system."
|
||||
! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] || [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then
|
||||
echo "IPv6 netmask/gateway obtained from SLAAC/DHCPv6 is different from old system."
|
||||
dhcpv6_or_slaac=false
|
||||
should_disable_ra_slaac=true
|
||||
flush_ipv6_config true
|
||||
should_disable_accept_ra=true
|
||||
should_disable_autoconf=true
|
||||
flush_ipv6_config
|
||||
add_missing_ipv6_config
|
||||
test_internet
|
||||
fi
|
||||
|
||||
# 如果是静态地址(包括动态无法上网而改成静态的),但是 RA 有网关且和正确的网关不同,要关闭 RA,避免自动设置网关
|
||||
# TODO: 测试 RA 给的网关和静态设置的网关的优先级
|
||||
if $ipv6_has_internet && ! $dhcpv6_or_slaac && $ra_has_gateway &&
|
||||
! [ "$(get_first_ipv6_gateway)" = "$ipv6_gateway_from_ra" ]; then
|
||||
echo "Ignore IPv6 gateway from RA."
|
||||
should_disable_accept_ra=true
|
||||
fi
|
||||
|
||||
# 要删除不联网协议的ip,因为
|
||||
# 1 甲骨文云管理面板添加ipv6地址然后取消
|
||||
# 依然会分配ipv6地址,但ipv6没网络
|
||||
# 此时alpine只会用ipv6下载apk,而不用会ipv4下载
|
||||
# 2 有ipv4地址但没有ipv4网关的情况(vultr),aria2会用ipv4下载
|
||||
if $ipv4_has_internet && ! $ipv6_has_internet; then
|
||||
echo 0 >"/proc/sys/net/ipv6/conf/$ethx/accept_ra"
|
||||
ip -6 addr flush scope global dev "$ethx"
|
||||
flush_ipv6_config
|
||||
elif ! $ipv4_has_internet && $ipv6_has_internet; then
|
||||
ip -4 addr flush scope global dev "$ethx"
|
||||
flush_ipv4_config
|
||||
fi
|
||||
|
||||
# 如果联网了,但没获取到默认 DNS,则添加我们的 DNS
|
||||
@ -442,7 +464,9 @@ fi
|
||||
netconf="/dev/netconf/$ethx"
|
||||
mkdir -p "$netconf"
|
||||
$dhcpv4 && echo 1 >"$netconf/dhcpv4" || echo 0 >"$netconf/dhcpv4"
|
||||
$should_disable_ra_slaac && echo 1 >"$netconf/should_disable_ra_slaac" || echo 0 >"$netconf/should_disable_ra_slaac"
|
||||
$dhcpv6_or_slaac && echo 1 >"$netconf/dhcpv6_or_slaac" || echo 0 >"$netconf/dhcpv6_or_slaac"
|
||||
$should_disable_accept_ra && echo 1 >"$netconf/should_disable_accept_ra" || echo 0 >"$netconf/should_disable_accept_ra"
|
||||
$should_disable_autoconf && echo 1 >"$netconf/should_disable_autoconf" || echo 0 >"$netconf/should_disable_autoconf"
|
||||
$is_in_china && echo 1 >"$netconf/is_in_china" || echo 0 >"$netconf/is_in_china"
|
||||
echo "$ethx" >"$netconf/ethx"
|
||||
echo "$mac_addr" >"$netconf/mac_addr"
|
||||
|
@ -142,18 +142,21 @@ if not exist reinstall.sh (
|
||||
call :chmod a+x %thisdir%reinstall.sh
|
||||
)
|
||||
|
||||
rem %* 无法处理 --iso https://x.com/?yyy=123
|
||||
rem 为每个参数添加引号,使参数正确传递到 bash
|
||||
for %%a in (%*) do (
|
||||
set "param=!param! "%%~a""
|
||||
)
|
||||
rem for %%a in (%*) do (
|
||||
rem set "param=!param! "%%~a""
|
||||
rem )
|
||||
|
||||
rem 方法1
|
||||
rem 转成 unix 格式,避免用户用 windows 记事本编辑后换行符不对
|
||||
%SystemDrive%\cygwin\bin\dos2unix -q '%thisdir%reinstall.sh'
|
||||
%SystemDrive%\cygwin\bin\bash -l -c '%thisdir%reinstall.sh !param!'
|
||||
|
||||
rem 方法2
|
||||
rem %SystemDrive%\cygwin\bin\bash reinstall.sh %*
|
||||
rem 再在 reinstall.sh 里运行 source /etc/profile
|
||||
rem 用 bash 运行
|
||||
rem %SystemDrive%\cygwin\bin\bash -l %thisdir%reinstall.sh %* 运行后会清屏
|
||||
rem 因此不能用 -l
|
||||
rem 这就需要在 reinstall.sh 里运行 source /etc/profile
|
||||
rem 或者添加 export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
||||
%SystemDrive%\cygwin\bin\bash %thisdir%reinstall.sh %*
|
||||
exit /b
|
||||
|
||||
|
||||
|
48
reinstall.sh
48
reinstall.sh
@ -21,6 +21,7 @@ WINDOWS_EXES='cmd powershell wmic reg diskpart netsh bcdedit mountvol'
|
||||
export LC_ALL=C
|
||||
|
||||
# 处理部分用户用 su 切换成 root 导致环境变量没 sbin 目录
|
||||
# 也能处理 cygwin bash 没有添加 -l 运行 reinstall.sh
|
||||
# 不要漏了最后的 $PATH,否则会找不到 windows 系统程序例如 diskpart
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
||||
|
||||
@ -3329,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 能否用云内核
|
||||
@ -3388,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
|
||||
@ -3405,6 +3424,8 @@ This script is outdated, please download reinstall.sh again.
|
||||
}
|
||||
|
||||
remove_useless_initrd_files() {
|
||||
info "slim initrd"
|
||||
|
||||
# 显示精简前的大小
|
||||
du -sh .
|
||||
|
||||
@ -3509,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: \
|
||||
@ -3601,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
|
||||
|
127
trans.sh
127
trans.sh
@ -612,15 +612,28 @@ is_staticv6() {
|
||||
return 1
|
||||
}
|
||||
|
||||
should_disable_ra_slaac() {
|
||||
get_netconf_to should_disable_ra_slaac
|
||||
is_dhcpv6_or_slaac() {
|
||||
get_netconf_to dhcpv6_or_slaac
|
||||
# shellcheck disable=SC2154
|
||||
[ "$should_disable_ra_slaac" = 1 ]
|
||||
[ "$dhcpv6_or_slaac" = 1 ]
|
||||
}
|
||||
|
||||
should_disable_accept_ra() {
|
||||
get_netconf_to should_disable_accept_ra
|
||||
# shellcheck disable=SC2154
|
||||
[ "$should_disable_accept_ra" = 1 ]
|
||||
}
|
||||
|
||||
should_disable_autoconf() {
|
||||
get_netconf_to should_disable_autoconf
|
||||
# shellcheck disable=SC2154
|
||||
[ "$should_disable_autoconf" = 1 ]
|
||||
}
|
||||
|
||||
is_slaac() {
|
||||
# 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1,不考虑 ra
|
||||
# 防止部分机器slaac/dhcpv6获取的ip/网关无法上网
|
||||
if should_disable_ra_slaac; then
|
||||
if ! is_dhcpv6_or_slaac; then
|
||||
return 1
|
||||
fi
|
||||
get_netconf_to slaac
|
||||
@ -629,8 +642,9 @@ is_slaac() {
|
||||
}
|
||||
|
||||
is_dhcpv6() {
|
||||
# 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1,不考虑 ra
|
||||
# 防止部分机器slaac/dhcpv6获取的ip/网关无法上网
|
||||
if should_disable_ra_slaac; then
|
||||
if ! is_dhcpv6_or_slaac; then
|
||||
return 1
|
||||
fi
|
||||
get_netconf_to dhcpv6
|
||||
@ -996,7 +1010,7 @@ EOF
|
||||
fi
|
||||
|
||||
# 禁用 ra
|
||||
if should_disable_ra_slaac; then
|
||||
if should_disable_accept_ra; then
|
||||
if [ "$distro" = alpine ]; then
|
||||
cat <<EOF >>$conf_file
|
||||
pre-up echo 0 >/proc/sys/net/ipv6/conf/$ethx/accept_ra
|
||||
@ -1004,6 +1018,19 @@ EOF
|
||||
else
|
||||
cat <<EOF >>$conf_file
|
||||
accept_ra 0
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
# 禁用 autoconf
|
||||
if should_disable_autoconf; then
|
||||
if [ "$distro" = alpine ]; then
|
||||
cat <<EOF >>$conf_file
|
||||
pre-up echo 0 >/proc/sys/net/ipv6/conf/$ethx/autoconf
|
||||
EOF
|
||||
else
|
||||
cat <<EOF >>$conf_file
|
||||
autoconf 0
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
@ -1134,15 +1161,17 @@ EOF
|
||||
# fi
|
||||
# ...
|
||||
|
||||
# 禁用 ra
|
||||
# 禁用 ra/autoconf
|
||||
local mode=1
|
||||
for ethx in $(get_eths); do
|
||||
if should_disable_ra_slaac; then
|
||||
mode=1
|
||||
if [ "$mode" = 1 ]; then
|
||||
if should_disable_accept_ra; then
|
||||
case "$mode" in
|
||||
1)
|
||||
cat <<EOF >>$conf_file
|
||||
boot.kernel.sysctl."net.ipv6.conf.$ethx.accept_ra" = false;
|
||||
EOF
|
||||
elif [ "$mode" = 2 ]; then
|
||||
;;
|
||||
2)
|
||||
# nixos 配置静态 ip 时用的是脚本
|
||||
# 好像因此不起作用
|
||||
cat <<EOF >>$conf_file
|
||||
@ -1152,7 +1181,8 @@ networking.dhcpcd.extraConfig =
|
||||
ipv6ra_noautoconf
|
||||
'';
|
||||
EOF
|
||||
elif [ "$mode" = 3 ]; then
|
||||
;;
|
||||
3)
|
||||
# 暂时没用到 networkd
|
||||
cat <<EOF >>$conf_file
|
||||
systemd.network.networks.$ethx = {
|
||||
@ -1162,10 +1192,22 @@ systemd.network.networks.$ethx = {
|
||||
};
|
||||
};
|
||||
EOF
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if should_disable_autoconf; then
|
||||
case "$mode" in
|
||||
1)
|
||||
cat <<EOF >>$conf_file
|
||||
boot.kernel.sysctl."net.ipv6.conf.$ethx.autoconf" = false;
|
||||
EOF
|
||||
;;
|
||||
2) ;;
|
||||
3) ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
install_alpine() {
|
||||
@ -2351,7 +2393,8 @@ create_cloud_init_network_config() {
|
||||
\"address\": \"$ipv6_addr\",
|
||||
\"gateway\": \"$ipv6_gateway\" }
|
||||
" $ci_file
|
||||
if should_disable_ra_slaac; then
|
||||
# 无法设置 autoconf = false ?
|
||||
if should_disable_accept_ra; then
|
||||
yq -i ".network.config[$config_id].accept-ra = false" $ci_file
|
||||
fi
|
||||
fi
|
||||
@ -4808,8 +4851,7 @@ install_windows() {
|
||||
info "Add drivers"
|
||||
|
||||
drv=/os/drivers
|
||||
mkdir -p "$drv" # 驱动下载临时文件夹
|
||||
mkdir -p "/wim/drivers" # boot.wim 驱动文件夹
|
||||
mkdir -p "$drv" # 驱动下载临时文件夹
|
||||
|
||||
# 这里有坑
|
||||
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
|
||||
@ -4869,6 +4911,9 @@ install_windows() {
|
||||
add_driver_gcp
|
||||
;;
|
||||
esac
|
||||
|
||||
# 自定义驱动
|
||||
add_driver_custom
|
||||
}
|
||||
|
||||
# aws nitro
|
||||
@ -5230,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')
|
||||
@ -5284,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
|
||||
|
||||
@ -5292,7 +5362,7 @@ install_windows() {
|
||||
-not -iname "*.pdb" \
|
||||
-not -iname "dpinst.exe" \
|
||||
"$@" \
|
||||
-exec cp -rfv {} /wim/drivers \;
|
||||
-exec cp -rfv {} "$dst" \;
|
||||
}
|
||||
|
||||
# 添加驱动
|
||||
@ -5320,6 +5390,7 @@ install_windows() {
|
||||
|
||||
# 复制安装脚本
|
||||
# https://slightlyovercomplicated.com/2016/11/07/windows-pe-startup-sequence-explained/
|
||||
# https://learn.microsoft.com/previous-versions/windows/it-pro/windows-vista/cc721977(v=ws.10)
|
||||
mv /wim/setup.exe /wim/setup.exe.disabled
|
||||
|
||||
# 如果有重复的 Windows/System32 文件夹,会提示找不到 winload.exe 无法引导
|
||||
@ -5328,6 +5399,26 @@ install_windows() {
|
||||
# shellcheck disable=SC2010
|
||||
system32_dir=$(ls -d /wim/*/*32 | grep -i windows/system32)
|
||||
download $confhome/windows-setup.bat $system32_dir/startnet.cmd
|
||||
# dism 手动释放镜像时用
|
||||
# sed -i "s|@image_name@|$image_name|" $system32_dir/startnet.cmd
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
if [ "$force_old_windows_setup" = 1 ]; then
|
||||
sed -i 's/ForceOldSetup=0/ForceOldSetup=1/i' $system32_dir/startnet.cmd
|
||||
fi
|
||||
|
||||
# Windows Thin PC 有 Windows\System32\winpeshl.ini
|
||||
# [LaunchApps]
|
||||
# %SYSTEMDRIVE%\windows\system32\drvload.exe, %SYSTEMDRIVE%\windows\inf\sdbus.inf
|
||||
# %SYSTEMDRIVE%\setup.exe
|
||||
if [ -f $system32_dir/winpeshl.ini ]; then
|
||||
info "mod winpeshl.ini"
|
||||
# https://learn.microsoft.com/previous-versions/windows/it-pro/windows-vista/cc721977(v=ws.10)
|
||||
# 两种方法都可以,第一种是原版命令
|
||||
sed -i 's|setup.exe|windows\\system32\\cmd.exe, "/k %SYSTEMROOT%\\system32\\startnet.cmd"|i' $system32_dir/winpeshl.ini
|
||||
# sed -i 's|setup.exe|windows\\system32\\startnet.cmd|i' $system32_dir/winpeshl.ini
|
||||
cat -n $system32_dir/winpeshl.ini
|
||||
fi
|
||||
|
||||
# 提交修改 boot.wim
|
||||
info "Unmount boot.wim"
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user