Compare commits

..

4 Commits

Author SHA1 Message Date
14c314d2bc windows: 适配 massgrave 新镜像链接 2026-01-07 20:30:33 +08:00
6ebe902624 docs: 更新文档 2026-01-07 20:30:32 +08:00
83a85b9ccf windows: 使用更准确的 intel nic 驱动链接 2026-01-07 20:30:32 +08:00
c2d36ed176 fnos: 优化飞牛安装
- 支持 bios + gpt
- 支持 arm
2026-01-07 20:30:31 +08:00
19 changed files with 1262 additions and 2348 deletions

View File

@ -23,6 +23,3 @@ charset = utf-8-bom
[*.{yml,yaml}] [*.{yml,yaml}]
indent_size = 2 indent_size = 2
[reinstall.sh]
shell_variant = bash

View File

@ -37,9 +37,7 @@ jobs:
${{ matrix.command }} netboot.xyz ${{ matrix.command }} netboot.xyz
${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz ${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz
${{ matrix.command }} windows --image-name='Windows Server blah' --iso https://aka.ms/HCIReleaseImage --username administrator ${{ matrix.command }} windows --image-name='Windows Server blah' --iso https://aka.ms/HCIReleaseImage
${{ matrix.command }} reset
# 测试失败例子 # 测试失败例子
# ${{ matrix.command }} wrong-os # ${{ matrix.command }} wrong-os

View File

@ -38,7 +38,6 @@ If this helped you, you can buy me a milk tea.
- [Feature 3. One-click reboot to Alpine Live OS](#feature-3-reboot-to--alpine-live-os) - [Feature 3. One-click reboot to Alpine Live OS](#feature-3-reboot-to--alpine-live-os)
- [Feature 4. One-click reboot to netboot.xyz](#feature-4-reboot-to--netbootxyz) - [Feature 4. One-click reboot to netboot.xyz](#feature-4-reboot-to--netbootxyz)
- [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso) - [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso)
- [Cancel the reinstallation](#cancel-the-reinstallation)
## System Requirements ## System Requirements
@ -51,14 +50,14 @@ The system requirements for the target system are as follows:
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB | | <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ | | <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 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://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://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 18.04 LTS - 26.04 LTS | 512 MB \* | 2 GB | | <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.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://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, 10 | 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, 10 | 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://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 Stream | 9, 10 | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 43, 44 | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB | | <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.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://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://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | Rolling | 512 MB | 5 GB |
@ -145,11 +144,11 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
> >
> This feature will erase **the entire hard disk** of the current system (including other partitions)! > This feature will erase **the entire hard disk** of the current system (including other partitions)!
> >
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation. > Data is priceless — please think twice before proceeding!
- Username `root`. The script prompts for a password. If left blank, a random one is generated. - Username `root`. The script prompts for a password. If left blank, a random one is generated.
- When installing the latest version, the version number does not need to be specified. - When installing the latest version, the version number does not need to be specified.
- Maximizes disk space utilization: no boot or swap partitions. - Maximizes disk space usage: no boot partition (except for Fedora) and no swap partition.
- Automatically selects different optimized kernels based on machine type, such as `Cloud` or `HWE` kernels. - Automatically selects different optimized kernels based on machine type, such as `Cloud` or `HWE` kernels.
- When installing Red Hat, you must provide the `qcow2` image link obtained from <https://access.redhat.com/downloads/content/rhel>. You can also install `qcow2` of other RHEL-based OS, such as `Alibaba Cloud Linux` and `TencentOS Server`. - When installing Red Hat, you must provide the `qcow2` image link obtained from <https://access.redhat.com/downloads/content/rhel>. You can also install `qcow2` of other RHEL-based OS, such as `Alibaba Cloud Linux` and `TencentOS Server`.
- After reinstallation, if you need to change the SSH port or switch to key-based login, make sure to also modify the files inside `/etc/ssh/sshd_config.d/`. - After reinstallation, if you need to change the SSH port or switch to key-based login, make sure to also modify the files inside `/etc/ssh/sshd_config.d/`.
@ -163,12 +162,12 @@ bash reinstall.sh anolis 7|8|23
centos 9|10 centos 9|10
fnos 1 fnos 1
nixos 25.11 nixos 25.11
fedora 43|44 fedora 42|43
debian 9|10|11|12|13 debian 9|10|11|12|13
opensuse 16.0|tumbleweed
openeuler 20.03|22.03|24.03
alpine 3.20|3.21|3.22|3.23 alpine 3.20|3.21|3.22|3.23
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal] opensuse 15.6|16.0|tumbleweed
openeuler 20.03|22.03|24.03|25.09
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
kali kali
arch arch
gentoo gentoo
@ -182,7 +181,7 @@ bash reinstall.sh anolis 7|8|23
- `--ssh-key KEY` Set up SSH login public key, [formatted as follows](#--ssh-key). When using public key, password is empty. - `--ssh-key KEY` Set up SSH login public key, [formatted as follows](#--ssh-key). When using public key, password is empty.
- `--ssh-port PORT` Change the SSH port (for log observation during installation and for the new system) - `--ssh-port PORT` Change the SSH port (for log observation during installation and for the new system)
- `--web-port PORT` Change the Web port (for log observation during installation only) - `--web-port PORT` Change the Web port (for log observation during installation only)
- `--frpc-config PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL of the configuration file. - `--frpc-toml PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
- `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection. - `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection.
- `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/target` for Debian/Kali and `/os` for other distros. - `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/target` for Debian/Kali and `/os` for other distros.
@ -232,7 +231,7 @@ bash reinstall.sh ubuntu --installer
> >
> This feature will erase **the entire hard disk** of the current system (including other partitions)! > This feature will erase **the entire hard disk** of the current system (including other partitions)!
> >
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation. > Data is priceless — please think twice before proceeding!
- Supports `raw` and fixed-size `vhd` image formats. Either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`. - Supports `raw` and fixed-size `vhd` image formats. Either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`.
- When deploy a Windows image, the system disk will be automatically expanded, and machines with a static IP will have their IP configured, and may take a few minutes after the first boot for the configuration to take effect. - When deploy a Windows image, the system disk will be automatically expanded, and machines with a static IP will have their IP configured, and may take a few minutes after the first boot for the configuration to take effect.
@ -248,29 +247,10 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
- `--rdp-port PORT` Change RDP port (DD Windows only) - `--rdp-port PORT` Change RDP port (DD Windows only)
- `--ssh-port PORT` Change SSH port (for log observation during installation) - `--ssh-port PORT` Change SSH port (for log observation during installation)
- `--web-port PORT` Change Web port (for log observation during installation) - `--web-port PORT` Change Web port (for log observation during installation)
- `--frpc-config PATH` Add frpc for intranet tunneling (DD Windows only). Parameter can be local filepath or HTTP URL of the configuration file. - `--frpc-toml PATH` Add frpc for intranet tunneling (DD Windows only). Parameter can be local filepath or HTTP URL
- `--cloud-data PATH_OR_URL` Inject cloud-init NoCloud configuration into the DD'd Linux image (DD Linux only)
- `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection. - `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection.
- `--hold 2` Prevent reboot after the DD process finishes. For SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted. - `--hold 2` Prevent reboot after the DD process finishes. For SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted.
> [!TIP]
>
> `--cloud-data` accepts a local directory path or an HTTP base URL. The directory must contain a `user-data` file; `meta-data` and `network-config` are optional:
>
> ```
> seed/
> ├── user-data # required
> ├── meta-data # optional
> └── network-config # optional
> ```
>
> ```bash
> # Local directory
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data /path/to/seed/
> # HTTP directory
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data "https://example.com/seed/"
> ```
> [!TIP] > [!TIP]
> >
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console). > Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
@ -299,7 +279,7 @@ bash reinstall.sh alpine --hold 1
- `--password PASSWORD` Set password - `--password PASSWORD` Set password
- `--ssh-port PORT` Change SSH port - `--ssh-port PORT` Change SSH port
- `--ssh-key KEY` Set up SSH login public key, [formatted as follows](#--ssh-key). When using public key, password is empty. - `--ssh-key KEY` Set up SSH login public key, [formatted as follows](#--ssh-key). When using public key, password is empty.
- `--frpc-config PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL of the configuration file. - `--frpc-toml PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
### Feature 4: Reboot to <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz ### Feature 4: Reboot to <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
@ -325,28 +305,27 @@ bash reinstall.sh netboot.xyz
> >
> This feature will erase **the entire hard disk** of the current system (including other partitions)! > This feature will erase **the entire hard disk** of the current system (including other partitions)!
> >
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation. > Data is priceless — please think twice before proceeding!
- The script prompts for a username. If left blank, will use `administrator`. - Username `administrator`. The script prompts for a password. If left blank, a random one is generated.
- The script prompts for a password. If left blank, will use a random one. - If remote login fails, try using the username `.\administrator`.
- If remote login fails, try adding `.\` before the username, for example, `.\administrator`.
- The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot. - The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot.
- Supports ISO images in any language. - Supports ISO images in any language.
- Automatically bypassing Windows 11 hardware requirements. - Supports bypassing Windows 11 hardware requirements.
#### Supported Systems #### Supported Systems
- Windows (Vista ~ 11) - Windows (Vista ~ 11)
- Windows Server (2008 ~ 2025) - Windows Server (2008 ~ 2025)
- Windows Server Essentials - Windows Server Essentials \*
- Windows Server (Semi) Annual Channel - Windows Server (Semi) Annual Channel \*
- Hyper-V Server - Hyper-V Server \*
- Azure Local (Azure Stack HCI) - Azure Local (Azure Stack HCI) \*
#### Method 1: Let the Script Automatically Search for ISO #### Method 1: Let the Script Automatically Search for ISO
- The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs. - The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs.
- Only supports ISOs searching for Windows 10, 11, Server 2019, 2022, 2025. - Systems marked with \* do not support automatic ISO searching.
```bash ```bash
bash reinstall.sh windows \ bash reinstall.sh windows \
@ -447,7 +426,6 @@ bash reinstall.sh windows \
#### Optional Parameters #### Optional Parameters
- `--username USERNAME` Set Username (for Windows only)
- `--password PASSWORD` Set Password - `--password PASSWORD` Set Password
- `--allow-ping` Configure Windows Firewall to Allow Ping Responses - `--allow-ping` Configure Windows Firewall to Allow Ping Responses
- `--rdp-port PORT` Change RDP port - `--rdp-port PORT` Change RDP port
@ -456,7 +434,7 @@ bash reinstall.sh windows \
- `--add-driver INF_OR_DIR` Add additional driver, specifying .inf path, or the folder contains .inf file. - `--add-driver INF_OR_DIR` Add additional driver, specifying .inf path, or the folder contains .inf file.
- The driver must be downloaded to current system first. - The driver must be downloaded to current system first.
- This parameter can be set multiple times to add different driver. - This parameter can be set multiple times to add different driver.
- `--frpc-config PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL of the configuration file. - `--frpc-toml PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
- `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection. - `--hold 1` Reboot only into install environment, without running installer, only for SSH connect to test network connection.
- `--hold 2` Allow SSH connections for modifying `boot.wim`, `install.wim` or other contents before rebooting into the official Windows installation program, with the disk mounted at `/os`. - `--hold 2` Allow SSH connections for modifying `boot.wim`, `install.wim` or other contents before rebooting into the official Windows installation program, with the disk mounted at `/os`.
@ -467,7 +445,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: [11th Gen Core][intel-vmd-gen11], [12th-15th Gen Core][intel-vmd-gen12-to-gen15], Network Adapter: [7][intel-nic-7], [8.x][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7], [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], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [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
@ -481,12 +459,13 @@ bash reinstall.sh windows \
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic [gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display [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 [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
[intel-vmd-gen11]: https://www.intel.com/content/www/us/en/download/849933/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-13th-gen-platforms.html [intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
[intel-vmd-gen12-to-gen15]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
[intel-nic-8]: https://web.archive.org/web/20250501043104/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-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-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-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/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]: 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-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-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
@ -548,24 +527,28 @@ Most ARM machines support installing latest Windows 11.
During the installation process, you might encounter a black screen, and the serial console may display `ConvertPages: failed to find range`, but neither issue affects the installation. During the installation process, you might encounter a black screen, and the serial console may display `ConvertPages: failed to find range`, but neither issue affects the installation.
| Compatibility | Cloud Provider | Instance Type | Issues | | Compatibility | Cloud Provider | Instance Type | Issues |
| ------------- | -------------- | ----------------------- | ----------------------------------------------------------------------------------- | | ------------- | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ✔️ | Azure | B2pts_v2 | | | ✔️ | Azure | B2pts_v2 | |
| ✔️ | AWS | T4g | | | ✔️ | Alibaba Cloud | g6r, c6r | |
| ✔️ | Scaleway | COPARM1 | | | ✔️ | Alibaba Cloud | g8y, c8y, r8y | There is a chance of hanging at the boot logo during restart; forced reboot will resolve it. |
| ✔️ | Gcore | | | | ✔️ | AWS | T4g | |
| | Alibaba Cloud | g6r, c6r, g8y, c8y, r8y | Might hanging at the boot logo during restart; forced reboot will resolve it. | | ✔️ | Scaleway | COPARM1 | |
| | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed. | | ✔️ | Gcore | | |
| | Google Cloud | t2a | Missing network card drivers | | | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed.<br />Manual loading of GPU drivers is required after installation. |
| ❌ | Google Cloud | t2a | Missing network card drivers |
### Cancel the reinstallation <details>
- If the script was run by mistake, you can run this command to cancel the reinstallation operation. <summary>Loading Graphics Driver on Oracle Cloud</summary>
- Must be run before rebooting.
```bash Log in to the server using Remote Desktop, open Device Manager, locate the graphics card, select "Update Driver," and choose `Red Hat VirtIO GPU DOD controller` from the list. There's no need to download the drivers in advance.
bash reinstall.sh reset
``` ![virtio-gpu-1](https://github.com/user-attachments/assets/503e1d82-4fa9-4486-917e-73326ad7c988)
![virtio-gpu-2](https://github.com/user-attachments/assets/bf3a9af6-13d8-4f93-9d6c-d3b2dbddb37d)
![virtio-gpu-3](https://github.com/user-attachments/assets/a9006a78-838f-45bf-a556-2dba193d3c03)
</details>
## Parameter Format ## Parameter Format
@ -584,14 +567,12 @@ bash reinstall.sh reset
According to the Law of Bug Conservation, fixing old bugs often introduces new ones. According to the Law of Bug Conservation, fixing old bugs often introduces new ones.
If a bug occurs, try using an older version to see if it works. If a new bug occurs, try using an older version to see if it works.
Go to <https://github.com/bin456789/reinstall/commits/main> and find the old versions `commit_id` on the right side. Go to <https://github.com/bin456789/reinstall/commits/main> and find the old versions `commit_id` on the right side.
Replace `xxxxxxxx` in the script below with the `commit_id` of an older version and run the script.
```bash ```bash
commit_id=xxxxxxxx commit_id=xxxxxxx
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_ curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
bash reinstall.sh ... bash reinstall.sh ...
@ -602,7 +583,6 @@ bash reinstall.sh ...
1. Fork this repository. 1. Fork this repository.
2. Modify the `confhome` and `confhome_cn` at the beginning of `reinstall.sh` and `reinstall.bat`. 2. Modify the `confhome` and `confhome_cn` at the beginning of `reinstall.sh` and `reinstall.bat`.
3. Make changes to the other code. 3. Make changes to the other code.
4. Download and run your `reinstall.sh` or `reinstall.bat`."
## Thanks ## Thanks

118
README.md
View File

@ -38,7 +38,6 @@
- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统) - [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz) - [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso) - [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
- [取消重装](#取消重装)
## 系统要求 ## 系统要求
@ -51,14 +50,14 @@
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB | | <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ | | <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 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://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://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 18.04 LTS - 26.04 LTS | 512 MB \* | 2 GB | | <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.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://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, 10 | 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, 10 | 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://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 Stream | 9, 10 | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 43, 44 | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 42, 43 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB | | <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB |
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB | | <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.11 | 512 MB | 5 GB |
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB | | <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
| <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | 滚动 | 512 MB | 5 GB | | <img width="16" height="16" src="https://www.gentoo.org/assets/img/logo/gentoo-g.png" /> Gentoo | 滚动 | 512 MB | 5 GB |
@ -145,11 +144,11 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
> >
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)! > 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
> >
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装 > 数据无价,请三思而后行!
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码 - 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
- 安装最新版可不输入版本号 - 安装最新版可不输入版本号
- 最大化利用磁盘空间:不含 boot swap 分区 - 最大化利用磁盘空间:不含 boot 分区Fedora 例外),不含 swap 分区
- 自动根据机器类型选择不同的优化内核,例如 `Cloud``HWE` 内核 - 自动根据机器类型选择不同的优化内核,例如 `Cloud``HWE` 内核
- 安装 Red Hat 时需填写 <https://access.redhat.com/downloads/content/rhel> 得到的 `qcow2` 镜像链接,也可以安装其它类 RHEL 系统的 `qcow2`,例如 `Alibaba Cloud Linux``TencentOS Server` - 安装 Red Hat 时需填写 <https://access.redhat.com/downloads/content/rhel> 得到的 `qcow2` 镜像链接,也可以安装其它类 RHEL 系统的 `qcow2`,例如 `Alibaba Cloud Linux``TencentOS Server`
- 重装后如需修改 SSH 端口或者改成密钥登录,注意还要修改 `/etc/ssh/sshd_config.d/` 里面的文件 - 重装后如需修改 SSH 端口或者改成密钥登录,注意还要修改 `/etc/ssh/sshd_config.d/` 里面的文件
@ -163,12 +162,12 @@ bash reinstall.sh anolis 7|8|23
centos 9|10 centos 9|10
fnos 1 fnos 1
nixos 25.11 nixos 25.11
fedora 43|44 fedora 42|43
debian 9|10|11|12|13 debian 9|10|11|12|13
opensuse 16.0|tumbleweed
openeuler 20.03|22.03|24.03
alpine 3.20|3.21|3.22|3.23 alpine 3.20|3.21|3.22|3.23
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal] opensuse 15.6|16.0|tumbleweed
openeuler 20.03|22.03|24.03|25.09
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
kali kali
arch arch
gentoo gentoo
@ -182,7 +181,7 @@ bash reinstall.sh anolis 7|8|23
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空 - `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统) - `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统)
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用) - `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
- `--frpc-config PATH` 添加 frpc 内网穿透,参数填配置文件的本地路径或 HTTP 链接 - `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性 - `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
- `--hold 2` 安装结束后不重启,用于 SSH 登录修改系统内容Debian/Kali 会挂载在 `/target`,其它系统会挂载在 `/os` - `--hold 2` 安装结束后不重启,用于 SSH 登录修改系统内容Debian/Kali 会挂载在 `/target`,其它系统会挂载在 `/os`
@ -232,7 +231,7 @@ bash reinstall.sh ubuntu --installer
> >
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)! > 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
> >
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装 > 数据无价,请三思而后行!
- 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst` - 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP可能首次开机几分钟后才生效 - DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP可能首次开机几分钟后才生效
@ -248,29 +247,10 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
- `--rdp-port PORT` 修改 RDP 端口 (仅限 DD Windows) - `--rdp-port PORT` 修改 RDP 端口 (仅限 DD Windows)
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用) - `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用) - `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
- `--frpc-config PATH` 添加 frpc 内网穿透(仅限 DD Windows参数填配置文件的本地路径或 HTTP 链接 - `--frpc-toml PATH` 添加 frpc 内网穿透(仅限 DD Windows参数填本地路径或 HTTP 链接
- `--cloud-data PATH_OR_URL` 为 DD Linux 镜像注入 cloud-init NoCloud 配置(仅限 DD Linux
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性 - `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
- `--hold 2` DD 结束后不重启,用于 SSH 登录修改系统内容Windows 系统会挂载在 `/os`Linux 系统**不会**自动挂载 - `--hold 2` DD 结束后不重启,用于 SSH 登录修改系统内容Windows 系统会挂载在 `/os`Linux 系统**不会**自动挂载
> [!TIP]
>
> `--cloud-data` 参数为本地目录或 HTTP 基础 URL目录须包含 `user-data` 文件,`meta-data`、`network-config` 可选:
>
> ```
> seed/
> ├── user-data # 必须
> ├── meta-data # 可选
> └── network-config # 可选
> ```
>
> ```bash
> # 使用本地目录
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data /path/to/seed/
> # 使用 HTTP 目录
> bash reinstall.sh dd --img "https://example.com/xxx.xz" --cloud-data "https://example.com/seed/"
> ```
> [!TIP] > [!TIP]
> >
> 可通过多种方式SSH、HTTP 80 端口、商家后台 VNC、串行控制台查看安装进度。 > 可通过多种方式SSH、HTTP 80 端口、商家后台 VNC、串行控制台查看安装进度。
@ -299,7 +279,7 @@ bash reinstall.sh alpine --hold 1
- `--password PASSWORD` 设置密码 - `--password PASSWORD` 设置密码
- `--ssh-port PORT` 修改 SSH 端口 - `--ssh-port PORT` 修改 SSH 端口
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空 - `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
- `--frpc-config PATH` 添加 frpc 内网穿透,参数填配置文件的本地路径或 HTTP 链接 - `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
### 功能 4: 重启到 <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz ### 功能 4: 重启到 <img width="16" height="16" src="https://netboot.xyz/img/favicon.ico" /> netboot.xyz
@ -325,28 +305,27 @@ bash reinstall.sh netboot.xyz
> >
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)! > 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
> >
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装 > 数据无价,请三思而后行!
- 脚本会提示输入用户名,不输入则使`administrator` -户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
- 脚本会提示输入密码,不输入则使用随机密码 - 如果远程登录失败,可以尝试使用用户名 `.\administrator`
- 如果远程登录失败,请尝试在用户名前添加 `.\`,例如 `.\administrator`
- 静态机器会自动配置好 IP可能首次开机几分钟后才生效 - 静态机器会自动配置好 IP可能首次开机几分钟后才生效
- 支持任意语言的 ISO - 支持任意语言的 ISO
- 自动绕过 Windows 11 硬件限制 - 支持绕过 Windows 11 硬件限制
#### 支持的系统 #### 支持的系统
- Windows (Vista ~ 11) - Windows (Vista ~ 11)
- Windows Server (2008 ~ 2025) - Windows Server (2008 ~ 2025)
- Windows Server Essentials - Windows Server Essentials \*
- Windows Server (Semi) Annual Channel - Windows Server (Semi) Annual Channel \*
- Hyper-V Server - Hyper-V Server \*
- Azure Local (Azure Stack HCI) - Azure Local (Azure Stack HCI) \*
#### 方法 1: 让脚本自动查找 ISO #### 方法 1: 让脚本自动查找 ISO
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO该网站专门提供官方 ISO 下载 - 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO该网站专门提供官方 ISO 下载
- 只支持查找 Windows 10, 11, Server 2019, 2022, 2025 的 ISO - 上面带 \* 的系统不支持自动查找 ISO
```bash ```bash
bash reinstall.sh windows \ bash reinstall.sh windows \
@ -447,7 +426,6 @@ bash reinstall.sh windows \
#### 可选参数 #### 可选参数
- `--username USERNAME` 设置用户名(仅限 Windows
- `--password PASSWORD` 设置密码 - `--password PASSWORD` 设置密码
- `--allow-ping` 设置 Windows 防火墙允许被 Ping - `--allow-ping` 设置 Windows 防火墙允许被 Ping
- `--rdp-port PORT` 更改 RDP 端口 - `--rdp-port PORT` 更改 RDP 端口
@ -456,7 +434,7 @@ bash reinstall.sh windows \
- `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹 - `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹
- 需先下载驱动到当前系统 - 需先下载驱动到当前系统
- 可多次设置该参数以添加不同的驱动 - 可多次设置该参数以添加不同的驱动
- `--frpc-config PATH` 添加 frpc 内网穿透,参数填配置文件的本地路径或 HTTP 链接 - `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性 - `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
- `--hold 2` 用于在进入 Windows 官方安装程序之前SSH 登录修改 `boot.wim``install.wim` 或者其它内容,硬盘挂载在 `/os` - `--hold 2` 用于在进入 Windows 官方安装程序之前SSH 登录修改 `boot.wim``install.wim` 或者其它内容,硬盘挂载在 `/os`
@ -467,7 +445,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 存储控制器: [11代酷睿][intel-vmd-gen11], [12-15代酷睿][intel-vmd-gen12-to-gen15], 网卡: [7][intel-nic-7], [8.x][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7], [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], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [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
@ -481,12 +459,13 @@ bash reinstall.sh windows \
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic [gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display [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 [azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
[intel-vmd-gen11]: https://www.intel.com/content/www/us/en/download/849933/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-13th-gen-platforms.html [intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
[intel-vmd-gen12-to-gen15]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html [intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
[intel-nic-8]: https://web.archive.org/web/20250501043104/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-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-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-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/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]: 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-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-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
@ -548,24 +527,28 @@ Windows Server 2025 SERVERDATACENTER
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装 安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
| 兼容性 | 云服务商 | 实例类型 | 问题 | | 兼容性 | 云服务商 | 实例类型 | 问题 |
| ------ | -------- | ----------------------- | ------------------------------------------ | | ------ | -------- | ------------- | ---------------------------------------------------------------------------- |
| ✔️ | Azure | B2pts_v2 | | | ✔️ | Azure | B2pts_v2 | |
| ✔️ | AWS | T4g | | | ✔️ | 阿里云 | g6r, c6r | |
| ✔️ | Scaleway | COPARM1 | | | ✔️ | 阿里云 | g8y, c8y, r8y | 有几率重启时卡开机 Logo强制重启即可 |
| ✔️ | Gcore | | | | ✔️ | AWS | T4g | |
| | 阿里云 | g6r, c6r, g8y, c8y, r8y | 有几率重启时卡开机 Logo强制重启即可 | | ✔️ | Scaleway | COPARM1 | |
| | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功 | | ✔️ | Gcore | | |
| | 谷歌云 | t2a | 缺少网卡驱动 | | | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功<br />安装后还需要手动加载显卡驱动 |
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
### 取消重装 <details>
- 如果不小心运行了脚本,可以运行以下命令取消重装 <summary>甲骨文云加载显卡驱动</summary>
- 需要在重启前运行
```bash 使用远程桌面登录到服务器,打开设备管理器,找到显卡,选择更新驱动,在列表中选择 `Red Hat VirtIO GPU DOD controller` 即可。不需要提前下载驱动。
bash reinstall.sh reset
``` ![virtio-gpu-1](https://github.com/user-attachments/assets/503e1d82-4fa9-4486-917e-73326ad7c988)
![virtio-gpu-2](https://github.com/user-attachments/assets/bf3a9af6-13d8-4f93-9d6c-d3b2dbddb37d)
![virtio-gpu-3](https://github.com/user-attachments/assets/a9006a78-838f-45bf-a556-2dba193d3c03)
</details>
## 参数格式 ## 参数格式
@ -584,14 +567,12 @@ bash reinstall.sh reset
根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug 根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug
如果脚本出现问题,可以试下旧版本是否正常 如果遇到新的 Bug,可以试下旧版本是否正常
<https://github.com/bin456789/reinstall/commits/main> 右侧找到旧版本的 `commit_id` <https://github.com/bin456789/reinstall/commits/main> 右侧找到旧版本的 `commit_id`
将下面脚本的 `xxxxxxxx` 替换成旧版本的 `commit_id` 并运行脚本
```bash ```bash
commit_id=xxxxxxxx commit_id=xxxxxxx
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_ curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
bash reinstall.sh ... bash reinstall.sh ...
@ -602,7 +583,6 @@ bash reinstall.sh ...
1. Fork 本仓库 1. Fork 本仓库
2. 修改 `reinstall.sh``reinstall.bat` 开头的 `confhome``confhome_cn` 2. 修改 `reinstall.sh``reinstall.bat` 开头的 `confhome``confhome_cn`
3. 修改其它代码 3. 修改其它代码
4. 下载并运行你的 `reinstall.sh``reinstall.bat`
## 感谢 ## 感谢

View File

@ -170,6 +170,47 @@ GatewayOnLink=yes
fi fi
} }
fix_wicked_conf() {
# https://github.com/openSUSE/wicked/wiki/FAQ#q-why-wicked-does-not-set-my-default-static-route
# 修改前
# default 1.1.1.1 - -
# default 2602::1 - -
# 修改后
# 1.1.1.1 - -
# 2602::1 - -
# default 1.1.1.1 - -
# default 2602::1 - -
if ! confs=$(ls "$os_dir/etc/sysconfig/network/ifroute-"* 2>/dev/null); then
return
fi
for conf in $confs; do
# 判断 bug 是否已经修复
if grep -v 'default' "$conf" | grep -q '-'; then
return
fi
# 获取网关
gateways=$(awk '$1=="default" {print $2}' "$conf")
if [ -z "$gateways" ]; then
return
fi
# 创建新条目
for gateway in $gateways; do
echo "$gateway - -"
done | insert_into_file "$conf" head
done
# 重新应用配置
if systemctl -q is-enabled wicked; then
systemctl restart wicked
fi
}
# ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理 # ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理
# debian 10/11 云镜像原本用 ifupdown + resolvconf脚本改成用 netplan + networkd/resolved # debian 10/11 云镜像原本用 ifupdown + resolvconf脚本改成用 netplan + networkd/resolved
@ -183,3 +224,6 @@ fix_netplan_conf
# 只需对云镜像处理 # 只需对云镜像处理
# 因为普通安装用的是 alpine 的 cloud-init版本够新不用处理 # 因为普通安装用的是 alpine 的 cloud-init版本够新不用处理
fix_networkd_conf fix_networkd_conf
# opensuse 15.5: ifcfg + netconfig (dns) + wicked
fix_wicked_conf

View File

@ -206,7 +206,7 @@ d-i preseed/early_command string true; \
ssh-keygen -A; \ ssh-keygen -A; \
run_as_service_with_screen /usr/sbin/sshd -D; \ run_as_service_with_screen /usr/sbin/sshd -D; \
if ls /configs/frpc.* >/dev/null 2>&1; then \ if [ -s /configs/frpc.toml ]; then \
url=$(sh /get-frpc-url.sh linux); \ url=$(sh /get-frpc-url.sh linux); \
mkdir -p /usr/local/bin; \ mkdir -p /usr/local/bin; \
mkdir -p /usr/local/etc/frpc; \ mkdir -p /usr/local/etc/frpc; \
@ -217,8 +217,8 @@ d-i preseed/early_command string true; \
sleep 5; \ sleep 5; \
done; \ done; \
chmod a+x /usr/local/bin/frpc; \ chmod a+x /usr/local/bin/frpc; \
cp /configs/frpc.* /usr/local/etc/frpc/; \ cp /configs/frpc.toml /usr/local/etc/frpc/; \
run_as_service_with_screen /usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.*; \ run_as_service_with_screen /usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.toml; \
fi; \ fi; \
if [ -d /cdrom/simple-cdd ]; then \ if [ -d /cdrom/simple-cdd ]; then \
@ -296,11 +296,11 @@ d-i preseed/late_command string true; \
echo "Port $ssh_port" >>/target/etc/ssh/sshd_config; \ echo "Port $ssh_port" >>/target/etc/ssh/sshd_config; \
fi; \ fi; \
if ls /configs/frpc.* >/dev/null 2>&1; then \ if [ -s /configs/frpc.toml ]; then \
mkdir -p /target/usr/local/bin; \ mkdir -p /target/usr/local/bin; \
mkdir -p /target/usr/local/etc/frpc; \ mkdir -p /target/usr/local/etc/frpc; \
cp /usr/local/bin/frpc /target/usr/local/bin/; \ cp /usr/local/bin/frpc /target/usr/local/bin/; \
cp /usr/local/etc/frpc/frpc.* /target/usr/local/etc/frpc/; \ cp /usr/local/etc/frpc/frpc.toml /target/usr/local/etc/frpc/; \
chmod a+x /target/usr/local/bin/frpc; \ chmod a+x /target/usr/local/bin/frpc; \
cp /frpc.service /target/etc/systemd/system/; \ cp /frpc.service /target/etc/systemd/system/; \
in-target systemctl enable frpc; \ in-target systemctl enable frpc; \

View File

@ -9,6 +9,10 @@ Before=network.service
Before=networking.service Before=networking.service
Before=systemd-networkd.service Before=systemd-networkd.service
Before=NetworkManager.service Before=NetworkManager.service
Before=wickedd-auto4.service
Before=wickedd-dhcp4.service
Before=wickedd-dhcp6.service
Before=wickedd.service
Before=network.target Before=network.target

View File

@ -5,68 +5,53 @@
set -eE set -eE
# openeuler 需等待 udev 将网卡名从 eth0 改为 enp3s0
sleep 10
# 不知道有没有用
if command -v udevadm >/dev/null; then
# udevadm trigger
udevadm settle
elif command -v mdev >/dev/null; then
mdev -sf
fi
# 本脚本在首次进入新系统后运行 # 本脚本在首次进入新系统后运行
# 将 trans 阶段生成的网络配置中的网卡名(eth0) 改为正确的网卡名,也适用于以下情况 # 将 trans 阶段生成的网络配置中的网卡名(eth0) 改为正确的网卡名,也适用于以下情况
# 1. alpine 要运行此脚本,因为安装后的内核可能有 netboot 没有的驱动 # 1. alpine 要运行此脚本,因为安装后的内核可能有 netboot 没有的驱动
# 2. dmit debian 普通内核(安装时)和云内核网卡名不一致 # 2. dmit debian 普通内核(安装时)和云内核网卡名不一致
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=928923 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=928923
# openeuler 需等待 udev 将网卡名从 eth0 改为 enp3s0 # todo: 删除 cloud-init
# openeuler 本脚本运行一秒后才有 enp3s0
# 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后
# 有些时候网卡名还会来回修改几次
# 因此需要等待网卡名稳定
# 不知道有没有用
if false; then
if command -v udevadm >/dev/null; then
# udevadm trigger
udevadm settle || true
elif command -v mdev >/dev/null; then
mdev -sf || true
fi
sleep 1
fi
has_eth=false # 是否检查到网卡
check_count=0 # 总检查次数
stable_count=0 # 网卡名稳定的次数
old_state=
while true; do
check_count=$((check_count + 1))
new_state=$(ip -o link | awk '$2 != "lo:"')
if [ -n "$new_state" ]; then
has_eth=true
fi
if $has_eth && [ "$old_state" = "$new_state" ]; then
stable_count=$((stable_count + 1))
else
stable_count=0
fi
old_state=$new_state
# 稳定 10 秒后退出循环
if $has_eth && [ "$stable_count" -ge 10 ]; then
break
fi
# 60 秒都没发现网卡则退出脚本
if ! $has_eth && [ "$check_count" -ge 60 ]; then
exit 1
fi
sleep 1
done
to_lower() { to_lower() {
tr '[:upper:]' '[:lower:]' tr '[:upper:]' '[:lower:]'
} }
retry() {
local max_try=$1
shift
for i in $(seq "$max_try"); do
if "$@"; then
return
else
ret=$?
if [ "$i" -ge "$max_try" ]; then
return $ret
fi
sleep 1
fi
done
}
# openeuler 本脚本运行一秒后才有 enp3s0
# 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后
# 因此需要等待网卡出现
get_ethx_by_mac() { get_ethx_by_mac() {
retry 10 _get_ethx_by_mac "$@"
}
_get_ethx_by_mac() {
mac=$(echo "$1" | to_lower) mac=$(echo "$1" | to_lower)
flag=$2 flag=$2

View File

@ -10,8 +10,8 @@ Type=simple
User=nobody User=nobody
Restart=on-failure Restart=on-failure
RestartSec=5s RestartSec=5s
ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.conf ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.toml
ExecReload=/usr/local/bin/frpc reload -c /usr/local/etc/frpc/frpc.conf ExecReload=/usr/local/bin/frpc reload -c /usr/local/etc/frpc/frpc.toml
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

@ -17,41 +17,14 @@ get_frpc_url() {
# 传入 windows 或者 linux # 传入 windows 或者 linux
local os_type=$1 local os_type=$1
local nt_ver=$2 local nt_ver=$2
local os_bit=${3:-64}
get_old_version() {
# 脚本不支持安装 32 位 linux 系统,因此不用管
if [ "$os_type" = windows ]; then
# 最早支持 toml 的版本是 0.52.0
# 最后支持 vista 的版本是 0.29.0
# 最后支持 32 位的版本是 0.51.3
# 最后支持 win7 的版本是 0.54.0
case "$os_bit" in
32)
case "$nt_ver" in
6.0) echo 0.29.0 ;; # vista
*) echo 0.51.3 ;; # win7+
esac
;;
64)
case "$nt_ver" in
6.0) echo 0.29.0 ;; # vista
6.1) echo 0.54.0 ;; # win7
# 目前最新版本 v0.66.0 依然可以在 win8 上运行
esac
;;
esac
fi
}
is_need_old_version() { is_need_old_version() {
[ -n "$(get_old_version)" ] [ "$nt_ver" = "6.0" ] || [ "$nt_ver" = "6.1" ]
} }
version=$( version=$(
if is_need_old_version; then if is_need_old_version; then
get_old_version echo 0.54.0
else else
# debian 11 initrd 没有 xargs awk # debian 11 initrd 没有 xargs awk
# debian 12 initrd 没有 xargs # debian 12 initrd 没有 xargs
@ -73,7 +46,7 @@ get_frpc_url() {
) )
if [ -z "$version" ]; then if [ -z "$version" ]; then
echo 'cannot find version' >&2 echo 'cannot find version'
return 1 return 1
fi fi
@ -91,7 +64,7 @@ get_frpc_url() {
# jsdelivr 不支持 github releases 文件 # jsdelivr 不支持 github releases 文件
if is_ipv6_only; then if is_ipv6_only; then
if is_need_old_version; then if is_need_old_version; then
echo 'NOT_SUPPORT' >&2 echo 'NOT_SUPPORT'
return 1 return 1
else else
echo https://mirrors.nju.edu.cn/github-release/fatedier/frp echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
@ -111,12 +84,7 @@ get_frpc_url() {
arch=$( arch=$(
case "$(uname -m)" in case "$(uname -m)" in
x86_64) x86_64) echo amd64 ;;
case "$os_bit" in
32) echo 386 ;;
64) echo amd64 ;;
esac
;;
aarch64) echo arm64 ;; aarch64) echo arm64 ;;
esac esac
) )

View File

@ -11,7 +11,6 @@ ipv4_gateway=$3
ipv6_addr=$4 ipv6_addr=$4
ipv6_gateway=$5 ipv6_gateway=$5
is_in_china=$6 is_in_china=$6
ipv6_extra_addrs=$7
DHCP_TIMEOUT=15 DHCP_TIMEOUT=15
DNS_FILE_TIMEOUT=5 DNS_FILE_TIMEOUT=5
@ -172,15 +171,6 @@ add_missing_ipv6_config() {
ip -6 route add default via "$ipv6_gateway" dev "$ethx" onlink ip -6 route add default via "$ipv6_gateway" dev "$ethx" onlink
fi fi
fi fi
# 添加额外的 IPv6 地址(逗号分隔)
if [ -n "$ipv6_extra_addrs" ]; then
printf '%s\n' "$ipv6_extra_addrs" | tr ',' '\n' | while IFS= read -r addr; do
if [ -n "$addr" ]; then
ip -6 addr add "$addr" dev "$ethx" 2>/dev/null || true
fi
done
fi
fi fi
} }
@ -355,14 +345,14 @@ EOF
db_progress INFO netcfg/link_detect_progress db_progress INFO netcfg/link_detect_progress
else else
# alpine # alpine
# h3c 移动云电脑使用 udhcpc 会重复提示 sending select因此添加 timeout 强制结束进程 # h3c 移动云电脑使用 udhcpc 会重复提示 sending select无法获得 ipv6
# dhcpcd 会配置租约时间,过期会移除 IP但我们的没有在后台运行 dhcpcd ,因此用 udhcpc # dhcpcd 会配置租约时间,过期会移除 IP但我们的没有在后台运行 dhcpcd ,因此用 udhcpc
method=udhcpc method=udhcpc
case "$method" in case "$method" in
udhcpc) udhcpc)
timeout $DHCP_TIMEOUT udhcpc -i "$ethx" -f -q -n || true udhcpc -i "$ethx" -f -q -n || true
timeout $DHCP_TIMEOUT udhcpc6 -i "$ethx" -f -q -n || true udhcpc6 -i "$ethx" -f -q -n || true
sleep $DNS_FILE_TIMEOUT # 好像不用等待写入 dns但是以防万一 sleep $DNS_FILE_TIMEOUT # 好像不用等待写入 dns但是以防万一
;; ;;
dhcpcd) dhcpcd)
@ -516,6 +506,5 @@ echo "$ipv4_addr" >"$netconf/ipv4_addr"
echo "$ipv4_gateway" >"$netconf/ipv4_gateway" echo "$ipv4_gateway" >"$netconf/ipv4_gateway"
echo "$ipv6_addr" >"$netconf/ipv6_addr" echo "$ipv6_addr" >"$netconf/ipv6_addr"
echo "$ipv6_gateway" >"$netconf/ipv6_gateway" echo "$ipv6_gateway" >"$netconf/ipv6_gateway"
echo "$ipv6_extra_addrs" >"$netconf/ipv6_extra_addrs"
$ipv4_has_internet && echo 1 >"$netconf/ipv4_has_internet" || echo 0 >"$netconf/ipv4_has_internet" $ipv4_has_internet && echo 1 >"$netconf/ipv4_has_internet" || echo 0 >"$netconf/ipv4_has_internet"
$ipv6_has_internet && echo 1 >"$netconf/ipv6_has_internet" || echo 0 >"$netconf/ipv6_has_internet" $ipv6_has_internet && echo 1 >"$netconf/ipv6_has_internet" || echo 0 >"$netconf/ipv6_has_internet"

File diff suppressed because it is too large Load Diff

1582
trans.sh

File diff suppressed because it is too large Load Diff

16
ttys.sh
View File

@ -7,24 +7,16 @@ prefix=$1
# 注意 debian initrd 没有 xargs # 注意 debian initrd 没有 xargs
# 最后一个 tty 是主 tty显示的信息最全 # 最后一个 tty 是主 tty显示的信息最全
is_first=true
if [ "$(uname -m)" = "aarch64" ]; then if [ "$(uname -m)" = "aarch64" ]; then
ttys="ttyS0 ttyAMA0 tty0" ttys="ttyS0 ttyAMA0 tty0"
else else
ttys="ttyS0 tty0" ttys="ttyS0 tty0"
fi fi
# 安装环境下 tty 不一定齐全
# hytron 有ttyS0 但无法写入
# 用于 cmdline 引导参数时不需要判断 tty 是否存在和可写
if [ "$prefix" = "console=" ]; then
is_for_cmdline=true
else
is_for_cmdline=false
fi
is_first=true
for tty in $ttys; do for tty in $ttys; do
if $is_for_cmdline || stty -g -F "/dev/$tty" >/dev/null 2>&1; then # hytron 有ttyS0 但无法写入
if stty -g -F "/dev/$tty" >/dev/null 2>&1; then
if $is_first; then if $is_first; then
is_first=false is_first=false
else else
@ -33,7 +25,7 @@ for tty in $ttys; do
printf "%s" "$prefix$tty" printf "%s" "$prefix$tty"
if $is_for_cmdline && if [ "$prefix" = "console=" ] &&
{ [ "$tty" = ttyS0 ] || [ "$tty" = ttyAMA0 ]; }; then { [ "$tty" = ttyS0 ] || [ "$tty" = ttyAMA0 ]; }; then
printf ",115200n8" printf ",115200n8"
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/ash #!/bin/ash
# shellcheck shell=dash # shellcheck shell=dash
# shellcheck disable=SC3001,SC3003,SC3010,SC3015 # shellcheck disable=SC3001,SC3003,SC3010
# reinstall.sh / trans.sh 共用此文件 # reinstall.sh / trans.sh 共用此文件
# grep 无法处理 UTF-16LE 编码的 inf有以下几种解决方法 # grep 无法处理 UTF-16LE 编码的 inf有以下几种解决方法
@ -239,27 +239,6 @@ list_files_from_inf() {
done < <(echo "$inf_txts") done < <(echo "$inf_txts")
} }
is_x_starts_with_y() {
[[ "$1" =~ ^"$2" ]]
}
is_x_ends_with_y() {
[[ "$1" =~ "$2"$ ]]
}
is_absolute_path() {
# 检查路径是否以/开头
# alpine ash 可用
# [[ "$1" = "/*" ]]
# bash 可用
# [[ "$1" = /* ]]
# 都可用
is_x_starts_with_y "$1" /
}
# windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动 # windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动
# 因此 DISM 导出驱动时,也就没有包含其它架构的驱动文件 # 因此 DISM 导出驱动时,也就没有包含其它架构的驱动文件
@ -305,11 +284,7 @@ get_path_in_correct_case() {
output="$output$part/" output="$output$part/"
else else
# 最后 part # 最后 part
if is_x_ends_with_y "$path" /; then output="$output$part"
output="$output$part/"
else
output="$output$part"
fi
fi fi
shift shift
done done

Binary file not shown.

View File

@ -49,22 +49,29 @@ if exist X:\custom_drivers\ (
rem 等待加载分区 rem 等待加载分区
call :sleep 5000 call :sleep 5000
echo rescan | diskpart echo rescan | diskpart
call :sleep 5000
rem 判断 efi 还是 bios
rem 或者用 https://learn.microsoft.com/windows-hardware/manufacture/desktop/boot-to-uefi-mode-or-legacy-bios-mode
rem pe 下没有 mountvol
echo list vol | diskpart | find "efi" && (
set BootType=efi
) || (
set BootType=bios
)
rem 获取 ProductType rem 获取 ProductType
rem for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v ProductType') do ( rem for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v ProductType') do (
rem set "ProductType=%%a" rem set "ProductType=%%a"
rem ) rem )
rem 获取 installer 卷 id rem 获取 BuildNumber
for /f "tokens=2" %%a in ('echo list vol ^| diskpart ^| find " installer "') do ( for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (
set "VolIndex=%%a" set "BuildNumber=%%a"
) )
rem 及时退出 rem 获取 installer 卷 id
if "%VolIndex%"=="" ( for /f "tokens=2" %%a in ('echo list vol ^| diskpart ^| find "installer"') do (
echo Error: Cannot find installer partition. >&2 set "VolIndex=%%a"
exit /b 1
) )
rem 将 installer 分区设为 Y 盘 rem 将 installer 分区设为 Y 盘
@ -80,63 +87,11 @@ rem wmic pagefile
rem 获取主硬盘 id rem 获取主硬盘 id
rem vista pe 没有 wmic因此用 diskpart rem vista pe 没有 wmic因此用 diskpart
(echo select vol %VolIndex% & echo list disk) | diskpart | find "* Disk " > X:\disk.txt
rem 法语版 win7 diskpart 始终输出法语,即使设置了 chcp 437因此不能用这个方法 for /f "tokens=3" %%a in (X:\disk.txt) do (
rem (echo select vol %VolIndex% & echo list disk) | diskpart | find "* Disk " > X:\disk.txt set "DiskIndex=%%a"
rem for /f "tokens=3" %%a in (X:\disk.txt) do (
rem set "DiskIndex=%%a"
rem )
rem PE 下没有 findstr因此不能从 wmic 的输出直接选出开头为 * 的行,要用复杂的方法取出磁盘编号
rem 输出 diskpart 结果到文件
(echo select vol %VolIndex% & echo list disk) | diskpart | find "* " > X:\disk.txt
type X:\disk.txt
rem 逐行读取文件
setlocal enabledelayedexpansion
for /f "delims=" %%a in (X:\disk.txt) do (
set "line=%%a"
rem 寻找 * 开头的行
call :is_x_starts_with_char_y "!line!" "*" && (
rem 注意在 for %%b in (!safe_line!) do 中 * 会展开成文件列表,因此要先删除 *
rem 下面用的方法是用 * 作为分割符,获取 * 后面的第一列
rem for /f 会自动忽略行首的分隔符
for /f "tokens=1 delims=*" %%i in ("!line!") do (
set "safe_line=%%i"
)
rem 遍历每一列,找到是数字的那一列,就是磁盘编号
for %%b in (!safe_line!) do (
call :is_number "%%b" && (
set "DiskIndex=%%b"
goto :found_main_disk
)
)
rem 普通 for 是把“一段话”里的“每个词”排成队,让一个变量(%%b轮流去当这些词
rem for /f 是把“一段话”拆成“几个零件”存在不同的变量里(%%i, %%j...
)
) )
:not_found_main_disk
echo Error: Cannot find main disk. >&2
exit /b 1
:found_main_disk
del X:\disk.txt del X:\disk.txt
endlocal & set "DiskIndex=%DiskIndex%"
rem 判断 efi 还是 bios
rem 或者用 https://learn.microsoft.com/windows-hardware/manufacture/desktop/boot-to-uefi-mode-or-legacy-bios-mode
rem pe 下没有 mountvol
echo list vol | diskpart | find " efi " && (
set BootType=efi
) || (
set BootType=bios
)
rem 这个变量会被 trans.sh 修改 rem 这个变量会被 trans.sh 修改
set is4kn=0 set is4kn=0
@ -150,7 +105,6 @@ rem 重新分区/格式化
(if "%BootType%"=="efi" ( (if "%BootType%"=="efi" (
echo select disk %DiskIndex% echo select disk %DiskIndex%
rem del
echo select part 1 echo select part 1
echo delete part override echo delete part override
echo select part 2 echo select part 2
@ -158,35 +112,26 @@ rem 重新分区/格式化
echo select part 3 echo select part 3
echo delete part override echo delete part override
rem 1
echo create part efi size=%EFISize% echo create part efi size=%EFISize%
echo format fs=fat32 quick echo format fs=fat32 quick
rem 2
echo create part msr size=16 echo create part msr size=16
rem 3
echo create part primary echo create part primary
echo format fs=ntfs quick echo format fs=ntfs quick
rem echo assign letter=Z rem echo assign letter=Z
) else ( ) else (
echo select disk %DiskIndex% echo select disk %DiskIndex%
rem del
echo select part 1 echo select part 1
echo delete part override rem echo delete part override
rem echo create part primary
rem 1
echo create part primary
echo format fs=ntfs quick echo format fs=ntfs quick
echo active echo active
rem echo assign letter=Z rem echo assign letter=Z
)) > X:\diskpart.txt )) > X:\diskpart.txt
rem 使用 diskpart /s ,出错不会执行剩下的 diskpart 命令 rem 使用 diskpart /s ,出错不会执行剩下的 diskpart 命令
rem 但是返回值始终是 0
diskpart /s X:\diskpart.txt diskpart /s X:\diskpart.txt
del X:\diskpart.txt del X:\diskpart.txt
@ -195,11 +140,6 @@ rem X boot.wim (ram)
rem Y installer rem Y installer
rem Z os rem Z os
rem 获取 BuildNumber
for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (
set "BuildNumber=%%a"
)
rem 旧版安装程序会自动在C盘设置虚拟内存新版安装程序(24h2)不会 rem 旧版安装程序会自动在C盘设置虚拟内存新版安装程序(24h2)不会
rem 如果不创建虚拟内存1g 内存的机器安装时会报错/杀进程 rem 如果不创建虚拟内存1g 内存的机器安装时会报错/杀进程
if %BuildNumber% GEQ 26040 ( if %BuildNumber% GEQ 26040 (
@ -240,25 +180,11 @@ rem 运行 ramdisk X:\setup.exe 的话
rem vista 会找不到安装源 rem vista 会找不到安装源
rem server 23h2 会无法运行 rem server 23h2 会无法运行
rem 使用 /installfrom 可以解决? rem 使用 /installfrom 可以解决?
if "%ForceOldSetup%"=="1" (
rem 有的精简版 iso install.wim 根目录没有 setup.exe
rem https://github.com/bin456789/reinstall/issues/578
if "%ForceOldSetup%"=="1" if exist Y:\sources\setup.exe (
set setup=Y:\sources\setup.exe set setup=Y:\sources\setup.exe
goto :SetupExeFound
)
if exist Y:\setup.exe (
set setup=Y:\setup.exe
) else if exist Y:\sources\setup.exe (
set setup=Y:\sources\setup.exe
) else if exist X:\setup.exe (
set setup=X:\setup.exe
) else ( ) else (
echo "Error: setup.exe not found." >&2 set setup=Y:\setup.exe
exit /b 1
) )
:SetupExeFound
if "%EnableUnattended%"=="1" ( if "%EnableUnattended%"=="1" (
set Unattended=/unattend:X:\windows.xml set Unattended=/unattend:X:\windows.xml
@ -296,27 +222,6 @@ echo on
%setup% %ResizeRecoveryPartition% %EMS% %Unattended% %setup% %ResizeRecoveryPartition% %EMS% %Unattended%
exit /b exit /b
:is_number
rem 尝试转换字符串为数字,如果转换失败则说明不是数字
rem 如果转换失败num 是 0
rem 这不影响参数是 0 时的判断
set /a "num=%~1" >nul 2>nul
if "%num%"=="%~1" (
exit /b 0
)
exit /b 1
:is_x_starts_with_char_y
set "tempStr=%~1"
if "%tempStr:~0,1%"=="%~2" (
exit /b 0
)
exit /b 1
:sleep :sleep
rem 没有加载网卡驱动,无法用 ping 来等待 rem 没有加载网卡驱动,无法用 ping 来等待
rem 没有 timeout 命令 rem 没有 timeout 命令
@ -341,12 +246,6 @@ exit /b
rem 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格 rem 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格
find /i "SCSIAdapter" "%~1" >nul find /i "SCSIAdapter" "%~1" >nul
if not errorlevel 1 ( if not errorlevel 1 (
rem 有 N 种方法安装驱动
rem 1. dism /online /add-driver /driver:"%~1" # PE 不支持 /online 添加驱动
rem 2. pnputil -i -a "%~1"
rem 3. devcon
rem 4. dpinst
rem 5. drvload 官方推荐 https://learn.microsoft.com/windows-hardware/manufacture/desktop/drvload-command-line-options
drvload "%~1" drvload "%~1"
) )
exit /b exit /b

View File

@ -86,7 +86,7 @@
<Order>4</Order> <Order>4</Order>
<Path>powercfg /setactive SCHEME_MIN</Path> <Path>powercfg /setactive SCHEME_MIN</Path>
</RunSynchronousCommand> </RunSynchronousCommand>
<!-- 按需启用 administrator 账户 --> <!-- 启用 administrator 账户 -->
<RunSynchronousCommand wcm:action="add"> <RunSynchronousCommand wcm:action="add">
<Order>5</Order> <Order>5</Order>
<!-- vista 没有自带 powershell --> <!-- vista 没有自带 powershell -->
@ -94,8 +94,7 @@
<!-- win7 此时无法用 wmic useraccount --> <!-- win7 此时无法用 wmic useraccount -->
<!-- <Path>wmic useraccount where "sid like '%-500'" set Disabled=false</Path> --> <!-- <Path>wmic useraccount where "sid like '%-500'" set Disabled=false</Path> -->
<!-- https://learn.microsoft.com/archive/technet-wiki/13813.localized-names-for-administrator-account-in-windows --> <!-- https://learn.microsoft.com/archive/technet-wiki/13813.localized-names-for-administrator-account-in-windows -->
<!-- %enable_administrator% 会被 trans.sh 替换成 1 或 0 --> <Path>cmd /c "for %a in (Administrator Administrador Administrateur Administratör Администратор Järjestelmänvalvoja Rendszergazda) do (net user %a /active:yes &amp;&amp; exit)"</Path>
<Path>cmd /c "if "%enable_administrator%"=="1" for %a in (Administrator Administrador Administrateur Administratör Администратор Järjestelmänvalvoja Rendszergazda) do (net user %a /active:yes &amp;&amp; exit)"</Path>
</RunSynchronousCommand> </RunSynchronousCommand>
<!-- 禁用保留空间 --> <!-- 禁用保留空间 -->
<RunSynchronousCommand wcm:action="add"> <RunSynchronousCommand wcm:action="add">
@ -153,24 +152,10 @@
<Value>%administrator_password%</Value> <Value>%administrator_password%</Value>
<PlainText>false</PlainText> <PlainText>false</PlainText>
</AdministratorPassword> </AdministratorPassword>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Name>%user_username%</Name>
<Password>
<Value>%user_password%</Value>
<PlainText>false</PlainText>
</Password>
<!-- 需要填英文的 Administrators任何语言都是 -->
<!-- https://learn.microsoft.com/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-useraccounts-localaccounts-localaccount-group -->
<Group>Administrators</Group>
</LocalAccount>
</LocalAccounts>
</UserAccounts> </UserAccounts>
<OOBE> <OOBE>
<HideEULAPage>true</HideEULAPage> <HideEULAPage>true</HideEULAPage>
<!-- 文档说请勿使用 SkipMachineOOBE 设置自动执行 OOBE --> <ProtectYourPC>3</ProtectYourPC>
<!-- 但是 Azure 的系统镜像也是用了 SkipMachineOOBE -->
<!-- https://learn.microsoft.com/windows-hardware/customize/desktop/automate-oobe -->
<SkipMachineOOBE>true</SkipMachineOOBE> <SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE> <SkipUserOOBE>true</SkipUserOOBE>
</OOBE> </OOBE>

View File

@ -1,59 +1,36 @@
param( param(
[string]$Namespace = "root\cimv2", [string]$Namespace,
[Parameter(Mandatory = $true)] [string]$Class, [string]$Class,
[string]$Filter, [string]$Filter,
[string]$Properties [string]$Properties
) )
# 预处理属性列表:如果有输入则处理成数组,否则保持为空数组 $propertiesToDisplay = if ($Properties) { $Properties.Split(",") } else { @("*") }
[string[]]$propertyList = if ($Properties) {
$Properties.Split(",") | ForEach-Object { $_.Trim() } $wmiQuery = @{
} Namespace = $Namespace
else { Class = $Class
@()
} }
# 检查是否支持 Get-Cimresult if ($Filter) {
$isSupportCim = [bool](Get-Command Get-Cimresult -ErrorAction SilentlyContinue) $wmiQuery.Filter = $Filter
# 构造查询参数
$queryParams = @{ Namespace = $Namespace }
if ($isSupportCim) { $queryParams.ClassName = $Class } else { $queryParams.Class = $Class }
if ($Filter) { $queryParams.Filter = $Filter }
# 限制查询属性,加快查询速度
# CIM 支持
# WIM 不支持
if ($isSupportCim -and $propertyList.Count -gt 0) {
$queryParams.Property = $propertyList
} }
# 执行查询 Get-WmiObject @wmiQuery | ForEach-Object {
$results = if ($isSupportCim) { Get-Cimresult @queryParams } else { Get-WmiObject @queryParams } $_.PSObject.Properties | Where-Object {
-not $_.Name.StartsWith("__") -and
($propertiesToDisplay -contains $_.Name -or $propertiesToDisplay -contains "*")
} | ForEach-Object {
$name = $_.Name
$value = $_.Value
# 遍历结果 # 改成 wmic 的输出格式
foreach ($result in $results) { if ($value -is [Array]) {
# 遍历属性 $formattedValue = ($value | ForEach-Object { "`"$_`"" }) -join ","
foreach ($property in $result.PSObject.Properties) { Write-Output "$name={$formattedValue}"
$name = $property.Name }
$value = $property.Value else {
Write-Output "$name=$value"
# 过滤系统属性
if ($name.StartsWith("__") -or $name -eq "CimresultProperties" -or $name -eq "CimClass") { continue }
# 只输出 propertyList 有的属性
# propertyList 为空表示不过滤
if ($propertyList.Count -eq 0 -or $propertyList -contains $name) {
# 改成 wmic 的输出格式
# 这里要注意 string 也是 IEnumerable
if ($value -isnot [string] -and $value -is [Collections.IEnumerable]) {
$formattedValue = ($value | ForEach-Object { "`"$_`"" }) -join ","
Write-Output "$name={$formattedValue}"
}
else {
Write-Output "$name=$value"
}
} }
} }
} }