diff --git a/.editorconfig b/.editorconfig
index f5df4e8..403a682 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,9 +8,13 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
-[windows.xml]
+[{windows.xml,windows-*.xml}]
end_of_line = crlf
+[windows-frpc.xml]
+charset = utf-16-le
+indent_size = 2
+
[*.{bat,cmd,ps1}]
end_of_line = crlf
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 8660461..891b9bb 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -7,10 +7,13 @@ assignees: ''
---
-原来的系统:
-要安装的系统:
-遇到的问题:截图或者登录 SSH 获取日志 /reinstall.log
+原来的系统 (Original system):
-Original system:
-System to be installed:
-Issues encountered: Screenshot or log in via SSH to get the logs from /reinstall.log
+要安装的系统 (System to be installed):
+
+遇到的问题 (Issue):
+
+
diff --git a/.github/workflows/run_reinstall.yml b/.github/workflows/run_reinstall.yml
index 143ed6e..c09b51d 100644
--- a/.github/workflows/run_reinstall.yml
+++ b/.github/workflows/run_reinstall.yml
@@ -8,7 +8,6 @@ jobs:
run:
name: 运行主程序
strategy:
- fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
include:
@@ -22,18 +21,19 @@ jobs:
git config --global core.autocrlf false
- uses: actions/checkout@v4
- run: |
- ${{ matrix.command }} centos
- ${{ matrix.command }} almalinux 8
- ${{ matrix.command }} rocky 9
- ${{ matrix.command }} fedora
+ # ${{ matrix.command }} centos
+ ${{ matrix.command }} almalinux
+ # ${{ matrix.command }} rocky
+ # ${{ matrix.command }} fedora
+ # ${{ matrix.command }} oracle
${{ matrix.command }} ubuntu
${{ matrix.command }} debian
${{ matrix.command }} debian --ci
- ${{ matrix.command }} kali
- ${{ matrix.command }} alpine
- ${{ matrix.command }} opensuse
- ${{ matrix.command }} arch
- ${{ matrix.command }} gentoo
+ # ${{ matrix.command }} kali
+ # ${{ matrix.command }} alpine
+ # ${{ matrix.command }} opensuse
+ # ${{ matrix.command }} arch
+ # ${{ matrix.command }} gentoo
${{ matrix.command }} netboot.xyz
${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz
diff --git a/.github/workflows/sync_to_gitlab.yml b/.github/workflows/sync_to_cnb.yml
similarity index 55%
rename from .github/workflows/sync_to_gitlab.yml
rename to .github/workflows/sync_to_cnb.yml
index eb35139..1369e4c 100644
--- a/.github/workflows/sync_to_gitlab.yml
+++ b/.github/workflows/sync_to_cnb.yml
@@ -1,10 +1,10 @@
-name: 同步到 Gitlab
+name: 同步到 CNB
on:
workflow_dispatch:
push:
jobs:
run:
- name: 同步到 Gitlab
+ name: 同步到 CNB
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@@ -12,7 +12,7 @@ jobs:
fetch-depth: 0
- uses: yesolutions/mirror-action@master
with:
- REMOTE: https://gitlab.com/bin456789/reinstall.git
- GIT_USERNAME: username
- GIT_PASSWORD: ${{ secrets.GITLAB_TOKEN }}
+ REMOTE: https://cnb.cool/bin456789/reinstall.git
+ GIT_USERNAME: cnb
+ GIT_PASSWORD: ${{ secrets.CNB_TOKEN }}
PUSH_ALL_REFS: false
diff --git a/.github/workflows/sync_to_gitlabcn.yml b/.github/workflows/sync_to_gitlabcn.yml
deleted file mode 100644
index 3f05944..0000000
--- a/.github/workflows/sync_to_gitlabcn.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: 同步到 Gitlab CN
-on:
- workflow_dispatch:
- push:
-jobs:
- run:
- name: 同步到 Gitlab CN
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- - uses: yesolutions/mirror-action@master
- with:
- REMOTE: https://jihulab.com/bin456789/reinstall.git
- GIT_USERNAME: username
- GIT_PASSWORD: ${{ secrets.JIHULAB_TOKEN }}
- PUSH_ALL_REFS: false
diff --git a/README.en.md b/README.en.md
index eb85fcc..62f990f 100644
--- a/README.en.md
+++ b/README.en.md
@@ -4,26 +4,40 @@
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
-[](https://github.com/XAMPPRocky/tokei)
-[](https://t.me/reinstall_os)
-[](https://github.com/sponsors/bin456789)
-
+[](https://github.com/XAMPPRocky/tokei_rs)
-One-Click Script to Reinstall System [中文](README.md)
+One-Click system reinstallation script for VPS [中文](README.md)
-[](https://github.com/sponsors/bin456789)
+## Introduction
-## Highlights
-
-- One-click Linux installation: Supports 19 common distributions.
-- One-click Windows installation: Uses the official ISO for installation instead of custom images. The script can automatically ~~retrieves the ISO link~~ and installs common drivers like `Virtio`.
-- Supports installation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux`
-- No need to input IP parameters; automatically recognizes dynamic and static IPs, supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `dual NIC`
+- One-click reinstallation to Linux: Supports 19 common distributions.
+- One-click reinstallation to Windows: Uses the official original ISO instead of custom images. The script can automatically fetch the ISO link and installs public cloud drivers like `VirtIO`.
+- Supports reinstallation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux`
+- Automatically configures IP and intelligently sets it as static or dynamic. Supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `IPv4/IPv6 on different NIC`
- Specially optimized for low-spec servers, requires less memory than the official netboot
- Uses partition table ID to identify hard drives throughout the process, ensuring no wrong disk is written
- Supports BIOS and EFI boot, and ARM Server
- No homemades image included, all resources are obtained in real-time from mirror sites
+If this helped you, you can buy me a milk tea.
+[](https://github.com/sponsors/bin456789)
+
+[](https://github.com/sponsors/bin456789)
+
+### Feedback
+
+[](https://github.com/bin456789/reinstall/issues)
+[](https://t.me/reinstall_os)
+
+## Quick Start
+
+- [Download](#download-current-system-is--linux)
+- [Feature 1. One-click reinstallation to Linux](#feature-1-install--linux)
+- [Feature 2. One-click DD Raw image to hard disk](#feature-2-dd-raw-image-to-hard-disk)
+- [Feature 3. One-click reboot to Alpine Live OS in-memory system](#feature-3-reboot-to--alpine-live-os-ram-os)
+- [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)
+
## System Requirements
The original system can be any system listed in the table.
@@ -32,22 +46,22 @@ The system requirements for the target system are as follows:
| System | Version | Memory | Disk |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------- |
-|
Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB |
-|
Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ |
+|
Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
+|
Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
-|
Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 512 MB \* | 2 GB |
+|
Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
-|
RHEL
AlmaLinux
Rocky
Oracle | 8, 9 | 512 MB \* | 5 GB |
+|
RHEL
AlmaLinux
Rocky
Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
-|
CentOS | 9, 10 | 512 MB \* | 5 GB |
-|
Fedora | 40, 41 | 512 MB \* | 5 GB |
-|
openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB |
-|
openSUSE | 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
-|
NixOS | 24.11 | 512 MB | 5 GB |
+|
CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
+|
Fedora | 42, 43 | 512 MB \* | 5 GB |
+|
openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
+|
openSUSE | Leap 15.6, 16.0, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
+|
NixOS | 25.11 | 512 MB | 5 GB |
|
Arch | Rolling | 512 MB | 5 GB |
|
Gentoo | Rolling | 512 MB | 5 GB |
-|
AOSC OS | Rolling | 512 MB | 5 GB |
-|
fnOS | Beta | 512 MB | 8 GB |
+|
AOSC OS | Rolling | 512 MB | 5 GB |
+|
fnOS | 1 | 512 MB | 8 GB |
|
Windows (DD) | Any | 512 MB | Depends on image |
|
Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
@@ -57,6 +71,13 @@ The system requirements for the target system are as follows:
^ Indicates requiring either 256 MB memory + 1.5 GB disk, or 512 MB memory + 1 GB disk
> [!WARNING]
+>
+> In theory it also supports dedicated servers and PCs
+>
+> but if you can use IPMI or a USB drive, this script is not recommended.
+
+> [!WARNING]
+>
> ❌ This script does not support OpenVZ or LXC virtual machines.
>
> Please use instead.
@@ -66,13 +87,13 @@ The system requirements for the target system are as follows:
For server outside China:
```bash
-curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O reinstall.sh $_
+curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O ${_##*/} $_
```
For server inside China:
```bash
-curl -O https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_
+curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O ${_##*/} $_
```
## Download (Current system is
Windows)
@@ -105,7 +126,7 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta
For server inside China:
```batch
-certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.bat
+certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.bat
```
## Usage
@@ -118,7 +139,13 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
### Feature 1: Install
Linux
-- The username is `root` with a default password of `123@@@`.
+> [!CAUTION]
+>
+> This feature will erase **the entire hard disk** of the current system (including other partitions)!
+>
+> Data is priceless — please think twice before proceeding!
+
+- 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.
- 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.
@@ -127,38 +154,43 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
```bash
bash reinstall.sh anolis 7|8|23
+ rocky 8|9|10
+ oracle 8|9|10
+ almalinux 8|9|10
opencloudos 8|9|23
- rocky 8|9
- redhat 8|9 --img="http://xxx.com/xxx.qcow2"
- oracle 8|9
- almalinux 8|9
centos 9|10
- fedora 40|41
- nixos 24.11
- debian 9|10|11|12
- opensuse 15.6|tumbleweed
- alpine 3.18|3.19|3.20|3.21
- openeuler 20.03|22.03|24.03|24.09
- ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal]
+ fnos 1
+ nixos 25.11
+ fedora 42|43
+ debian 9|10|11|12|13
+ alpine 3.20|3.21|3.22|3.23
+ 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
arch
gentoo
aosc
- fnos
+ redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
```
#### Optional Parameters
- `--password PASSWORD` Set the password
+- `--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)
-- `--web-port PORT` Change the Web port (for log observation during installation)
-- `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali).
+- `--web-port PORT` Change the Web port (for log observation during installation only)
+- `--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 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.
> [!TIP]
-> When installing Debian/Kali, x86 architectures can monitor the installation progress through VNC in the background, while ARM architectures can use the serial console.
>
-> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
->
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
+> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
+>
+> Even if errors occur during the installation process, SSH is available for manual recovery.
+>
+> If the target system is not Debian/Kali, run `/trans.sh alpine` can automatically recover to Alpine Linux.
@@ -192,9 +224,15 @@ bash reinstall.sh ubuntu --installer
-### Feature 2: DD
+### Feature 2: DD RAW image to hard disk
-- Supports `raw` and `vhd` image formats (either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`).
+> [!CAUTION]
+>
+> This feature will erase **the entire hard disk** of the current system (including other partitions)!
+>
+> 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`.
- 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 Linux image, will **NOT** modify any contents of the image.
@@ -202,37 +240,55 @@ bash reinstall.sh ubuntu --installer
bash reinstall.sh dd --img "https://example.com/xxx.xz"
```
-#### Optional parameters
+#### Optional Parameters
-- `--allow-ping` Allow ping responses (DD Windows only)
+- `--allow-ping` Configure Windows Firewall to Allow Ping Responses (DD Windows only)
- `--rdp-port PORT` Change RDP port (DD Windows only)
- `--ssh-port PORT` Change SSH port (for log observation during installation)
- `--web-port PORT` Change Web port (for log observation during installation)
-- `--hold 2` Prevent reboot after the DD process finishes, allowing SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted.
+- `--frpc-toml PATH` Add frpc for intranet tunneling (DD Windows only). 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 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]
-> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
->
Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
+>
+> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
+>
+> Even if errors occur during the installation process, SSH is available for manual recovery.
+>
+> Or Run `/trans.sh alpine` to automatically recover to Alpine Linux.
### Feature 3: Reboot to
Alpine Live OS (RAM OS)
-- You can use SSH to backup/restore disk, manually perform DD operations, modify partitions, and manually install Alpine, Arch, Gentoo, and other systems.
-- Username `root`, Default password `123@@@`
-- If manual operations do not damage the original system, rebooting will return to the original system.
+- You can use SSH to backup/restore disk, manually perform DD operations, partition modifications, manual Alpine installation, and other operations.
+- Username `root`. The script prompts for a password. If left blank, a random one is generated.
+
+> [!TIP]
+>
+> Although the script being run is `reinstall`, this feature **does not** delete any data or perform an automatic reinstallation; manual user operation is required.
+
+> If the user does not damage the original system during manual operation, rebooting will return to the original system.
```bash
-bash reinstall.sh alpine --hold=1
+bash reinstall.sh alpine --hold 1
```
-#### Optional parameters
+#### Optional Parameters
- `--password PASSWORD` Set password
- `--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.
+- `--frpc-toml PATH` Add frpc for intranet tunneling. Parameter can be local filepath or HTTP URL
### Feature 4: Reboot to
netboot.xyz
- Can manually install [more systems](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz) using vendor backend VNC.
-- If manual operations do not damage the original system, rebooting will return to the original system.
+
+> [!TIP]
+>
+> Although the script being run is `reinstall`, this feature **does not** delete any data or perform an automatic reinstallation; manual user operation is required.
+
+> If the user does not damage the original system during manual operation, rebooting will return to the original system.
```bash
bash reinstall.sh netboot.xyz
@@ -244,10 +300,17 @@ bash reinstall.sh netboot.xyz

-- Username `administrator`, Default password `123@@@`
+> [!CAUTION]
+>
+> This feature will erase **the entire hard disk** of the current system (including other partitions)!
+>
+> Data is priceless — please think twice before proceeding!
+
+- Username `administrator`. The script prompts for a password. If left blank, a random one is generated.
- If remote login fails, try using the username `.\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.
-- Supports all languages.
+- Supports ISO images in any language.
+- Supports bypassing Windows 11 hardware requirements.
#### Supported Systems
@@ -256,12 +319,9 @@ bash reinstall.sh netboot.xyz
- Windows Server Essentials \*
- Windows Server (Semi) Annual Channel \*
- Hyper-V Server \*
- - Azure Stack HCI \*
+ - Azure Local (Azure Stack HCI) \*
-#### ~~Method 1: Let the Script Automatically Search for ISO~~
-
-> [!CAUTION]
-> The ISO repository currently prohibits direct link downloads, so this method is no longer effective.
+#### Method 1: Let the Script Automatically Search for ISO
- The script will search for ISOs from , a site that collects official ISOs.
- Systems marked with \* do not support automatic ISO searching.
@@ -325,7 +385,7 @@ zh-tw
```bash
bash reinstall.sh windows \
- --image-name "Windows 11 Enterprise LTSC 2024" \
+ --image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
```
@@ -350,7 +410,6 @@ bash reinstall.sh windows \
-
-
- Evaluation
- -
-
-
-
@@ -364,30 +423,58 @@ bash reinstall.sh windows \
-#### Optional parameters
+#### Optional Parameters
- `--password PASSWORD` Set Password
-- `--allow-ping` Configures the Windows firewall to allow ping requests
+- `--allow-ping` Configure Windows Firewall to Allow Ping Responses
- `--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)
+- `--ssh-port PORT` Change SSH port (for log observation during installation only)
+- `--web-port PORT` Change Web port (for log observation during installation only)
- `--add-driver INF_OR_DIR` Add additional driver, specifying .inf path, or the folder contains .inf file.
- - The driver must be downloaded locally first.
+ - The driver must be downloaded to current system first.
- This parameter can be set multiple times to add different driver.
-- `--hold 2` Allow SSH connections for modifying the disk content before rebooting into the official Windows installation program, with the disk mounted at `/os`.
+- `--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 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`.
#### The following drivers will automatic download and install as needed, without the need for manual addition
-- Virtio ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/), [Alibaba Cloud](https://www.alibabacloud.com/help/ecs/user-guide/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))
+- VirtIO ([Community][virtio-virtio], [Alibaba Cloud][virtio-aliyun], [Tencent Cloud][virtio-qcloud], [GCP][virtio-gcp])
+- XEN ([~~Community~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws])
+- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
+- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
+- Azure ([MANA Network Adapter][azure-mana])
+- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7], [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-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
+[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff
+[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public
+[xen-xen]: https://xenproject.org/resources/downloads/
+[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
+[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade
+[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html
+[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html
+[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
+[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
+[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
+[intel-vmd]: https://www.intel.com/content/www/us/en/download/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-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-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
+[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
+[intel-nic-2008-r2]: 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-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
+[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
+[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html
+[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html
+[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html
#### How to Specify the Image Name `--image-name`
-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.
+An ISO usually contains multiple system editions, such as Home and Pro. Therefore, you need to use `--image-name` to specify the system edition (image name) to install, case-insensitive.
You can use tools like DISM, DISM++, or Wimlib to query the image names included in the ISO.
@@ -410,18 +497,32 @@ Open File menu > Open Image File, select the iso to be installed to get the imag
> Vista (Server 2008) and 32-bit systems may lack drivers.
> [!WARNING]
-> For EFI machines without CSM enabled, Windows 7 (Server 2008 R2) cannot be installed.
>
-> Hyper-V (Azure) requires selecting the appropriate VM generation:
+> For Windows 7 (Server 2008 R2) installation:
+>
+> 1. EFI-boot machines must enable CSM.
+>
+> 2. On Hyper-V (Azure), select Generation 1 VM.
> [!WARNING]
+>
> In the Chinese version of Windows 10 LTSC 2021 ISO `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`, the `wsappx` process may indefinitely consume CPU resources.
>
> The solution is to update the system patches or manually install the `VCLibs` library .
+> [!WARNING]
+>
+> When installing Windows ISOs released in `May 2022` or later on GCP, the system may repeatedly reboot during the Windows installation (PE) stage. You can resolve this issue using one of the following two methods:
+>
+> 1. Add the `--force-boot-mode bios` parameter. The script will install Windows in `BIOS boot + MBR partition table` mode.
+>
+> (Optional) After installation, you can convert it to `EFI boot + GPT partition table` using the command `MBR2GPT /convert /allowFullOS`.
+>
+> 2. Create a custom RAW image and install it via DD.
+
#### Considerations for Installing Windows on ARM
-Most ARM machines support installing Windows 11 24H2.
+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.
@@ -448,10 +549,33 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
-## Discussion
+## Parameter Format
-[](https://github.com/bin456789/reinstall/issues)
-[](https://t.me/reinstall_os)
+### --ssh-key
+
+- `--ssh-key "ssh-rsa ..."`
+- `--ssh-key "ssh-ed25519 ..."`
+- `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."`
+- `--ssh-key http://path/to/public_key`
+- `--ssh-key github:your_username`
+- `--ssh-key gitlab:your_username`
+- `--ssh-key /path/to/public_key`
+- `--ssh-key C:\path\to\public_key`
+
+## How to Use an Old Version
+
+According to the Law of Bug Conservation, fixing old bugs often introduces new ones.
+
+If a new bug occurs, try using an older version to see if it works.
+
+Go to and find the old version’s `commit_id` on the right side.
+
+```bash
+commit_id=xxxxxxx
+curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
+sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
+bash reinstall.sh ...
+```
## How to Modify the Script for Your Own
@@ -461,8 +585,6 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
## Thanks
-[](https://github.com/sponsors/bin456789)
-
Thanks to the following businesses for providing free servers.
[](https://www.oracle.com/cloud/)
diff --git a/README.md b/README.md
index 89e83d1..436e5cd 100644
--- a/README.md
+++ b/README.md
@@ -4,26 +4,40 @@
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
-[](https://github.com/XAMPPRocky/tokei)
-[](https://t.me/reinstall_os)
-[](https://github.com/sponsors/bin456789)
-
+[](https://github.com/XAMPPRocky/tokei_rs)
-一键重装脚本 [English](README.en.md)
+一键 VPS 系统重装脚本 [English](README.en.md)
-[](https://github.com/sponsors/bin456789)
+## 介绍
-## 亮点
-
-- 一键安装 Linux,支持 19 种常见发行版
-- 一键安装 Windows,使用官方 ISO 安装而非自制镜像,~~脚本会自动获取 ISO 链接~~、自动安装 Virtio 等常见驱动
+- 一键重装到 Linux,支持 19 种常见发行版
+- 一键重装到 Windows,使用官方原版 ISO 而非自制镜像,脚本支持自动查找 ISO 链接、自动安装 `VirtIO` 等公有云驱动
- 支持任意方向重装,即 `Linux to Linux`、`Linux to Windows`、`Windows to Windows`、`Windows to Linux`
-- 无需填写 IP 参数,自动识别动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`双网卡`
+- 自动设置 IP,智能设置动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`IPv4/IPv6 在不同的网卡`
- 专门适配低配小鸡,比官方 netboot 需要更少的内存
- 全程用分区表 ID 识别硬盘,确保不会写错硬盘
- 支持 BIOS、EFI 引导,支持 ARM 服务器
- 不含自制包,所有资源均实时从镜像源获得
+如果帮到你,可以请我喝奶茶。
+[](https://github.com/sponsors/bin456789)
+
+[](https://github.com/sponsors/bin456789)
+
+### 反馈
+
+[](https://github.com/bin456789/reinstall/issues)
+[](https://t.me/reinstall_os)
+
+## 快速开始
+
+- [下载](#下载当前系统是--linux)
+- [功能 1. 一键重装到 Linux](#功能-1-安装--linux)
+- [功能 2. 一键 DD Raw 镜像到硬盘](#功能-2-dd-raw-镜像到硬盘)
+- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
+- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
+- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
+
## 系统要求
原系统可以是表格中的任意系统
@@ -32,22 +46,22 @@
| 系统 | 版本 | 内存 | 硬盘 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
-|
Alpine | 3.18, 3.19, 3.20, 3.21 | 256 MB | 1 GB |
-|
Debian | 9, 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ |
+|
Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
+|
Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
-|
Ubuntu | 16.04 LTS - 24.04 LTS, 24.10 | 512 MB \* | 2 GB |
+|
Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
-|
RHEL
AlmaLinux
Rocky
Oracle | 8, 9 | 512 MB \* | 5 GB |
+|
RHEL
AlmaLinux
Rocky
Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
-|
CentOS | 9, 10 | 512 MB \* | 5 GB |
-|
Fedora | 40, 41 | 512 MB \* | 5 GB |
-|
openEuler | 20.03 LTS - 24.03 LTS, 24.09 | 512 MB \* | 5 GB |
-|
openSUSE | 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
-|
NixOS | 24.11 | 512 MB | 5 GB |
+|
CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
+|
Fedora | 42, 43 | 512 MB \* | 5 GB |
+|
openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
+|
openSUSE | Leap 15.6, 16.0, Tumbleweed (滚动) | 512 MB \* | 5 GB |
+|
NixOS | 25.11 | 512 MB | 5 GB |
|
Arch | 滚动 | 512 MB | 5 GB |
|
Gentoo | 滚动 | 512 MB | 5 GB |
-|
安同 OS | 滚动 | 512 MB | 5 GB |
-|
飞牛 fnOS | 公测 | 512 MB | 8 GB |
+|
安同 OS | 滚动 | 512 MB | 5 GB |
+|
飞牛 fnOS | 1 | 512 MB | 8 GB |
|
Windows (DD) | 任何 | 512 MB | 取决于镜像 |
|
Windows (ISO) | Vista, 7, 8.x (Server 2008 - 2012 R2) | 512 MB | 25 GB |
|
Windows (ISO) | 10, 11 (Server 2016 - 2025) | 1 GB | 25 GB |
@@ -57,6 +71,13 @@
^ 表示需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
> [!WARNING]
+>
+> 本脚本理论上支持独服和 PC
+>
+> 但如果能使用 IPMI 或 U 盘,则不建议使用本脚本
+
+> [!WARNING]
+>
> ❌ 本脚本不支持 OpenVZ、LXC 虚拟机
>
> 请改用
@@ -66,13 +87,13 @@
国外服务器:
```bash
-curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O reinstall.sh $_
+curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh || wget -O ${_##*/} $_
```
国内服务器:
```bash
-curl -O https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.sh || wget -O reinstall.sh $_
+curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O ${_##*/} $_
```
## 下载(当前系统是
Windows)
@@ -105,7 +126,7 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta
国内服务器:
```batch
-certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/reinstall.bat
+certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.bat
```
## 使用
@@ -114,11 +135,17 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
- Linux 下运行 `bash reinstall.sh ...`
- Windows 下先运行 `cmd`,再运行 `reinstall.bat ...`
- - 如果参数中的链接包含特殊字符,要用 `""` 将链接包起来,不能用 `''`
+ - 如果参数中的链接包含特殊字符,要用 `""` 将链接包裹起来,不能用 `''`
### 功能 1: 安装
Linux
-- 用户名 `root` 默认密码 `123@@@`
+> [!CAUTION]
+>
+> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
+>
+> 数据无价,请三思而后行!
+
+- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
- 安装最新版可不输入版本号
- 最大化利用磁盘空间:不含 boot 分区(Fedora 例外),不含 swap 分区
- 自动根据机器类型选择不同的优化内核,例如 `Cloud`、`HWE` 内核
@@ -127,38 +154,43 @@ certutil -urlcache -f -split https://gitlab.com/bin456789/reinstall/-/raw/main/r
```bash
bash reinstall.sh anolis 7|8|23
+ rocky 8|9|10
+ oracle 8|9|10
+ almalinux 8|9|10
opencloudos 8|9|23
- rocky 8|9
- redhat 8|9 --img="http://xxx.com/xxx.qcow2"
- oracle 8|9
- almalinux 8|9
centos 9|10
- fedora 40|41
- nixos 24.11
- debian 9|10|11|12
- opensuse 15.6|tumbleweed
- alpine 3.18|3.19|3.20|3.21
- openeuler 20.03|22.03|24.03|24.09
- ubuntu 16.04|18.04|20.04|22.04|24.04|24.10 [--minimal]
+ fnos 1
+ nixos 25.11
+ fedora 42|43
+ debian 9|10|11|12|13
+ alpine 3.20|3.21|3.22|3.23
+ 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
arch
gentoo
aosc
- fnos
+ redhat --img="http://access.cdn.redhat.com/xxx.qcow2"
```
#### 可选参数
- `--password PASSWORD` 设置密码
-- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也用于新系统)
+- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
+- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统)
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
-- `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali)
+- `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
+- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
+- `--hold 2` 安装结束后不重启,用于 SSH 登录修改系统内容,Debian/Kali 会挂载在 `/target`,其它系统会挂载在 `/os`
> [!TIP]
-> 安装 Debian/Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。
>
-> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
->
即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
+> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
+>
+> 即使安装过程出错,也能连接 SSH 手动救砖。
+>
+> 目标系统非 Debian/Kali 时,可以运行 `/trans.sh alpine` 自动救砖成 Alpine 系统。
@@ -192,9 +224,15 @@ bash reinstall.sh ubuntu --installer
-### 功能 2: DD
+### 功能 2: DD RAW 镜像到硬盘
-- 支持 `raw` `vhd` 格式的镜像(未压缩,或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`)
+> [!CAUTION]
+>
+> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
+>
+> 数据无价,请三思而后行!
+
+- 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
- DD Linux 镜像时,**不会**修改镜像的任何内容
@@ -204,35 +242,53 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
#### 可选参数
-- `--allow-ping` 允许被 Ping (仅限 DD Windows)
+- `--allow-ping` 设置 Windows 防火墙允许被 Ping (仅限 DD Windows)
- `--rdp-port PORT` 修改 RDP 端口 (仅限 DD Windows)
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
-- `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
+- `--frpc-toml PATH` 添加 frpc 内网穿透(仅限 DD Windows),参数填本地路径或 HTTP 链接
+- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
+- `--hold 2` DD 结束后不重启,用于 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
> [!TIP]
-> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
->
即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
+>
+> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
+>
+> 即使安装过程出错,也能连接 SSH 手动救砖
+>
+> 也可以运行 `/trans.sh alpine` 自动救砖成 Alpine 系统。
### 功能 3: 重启到
Alpine Live OS(内存系统)
-- 可用 ssh 连接,进行备份/恢复硬盘、手动 DD、修改分区、手动安装 Alpine/Arch/Gentoo 等操作
-- 用户名 `root` 默认密码 `123@@@`
-- 如果手动操作没有破坏原系统,再次重启将回到原系统
+- 可用 ssh 连接,进行备份/恢复硬盘、手动 DD、修改分区、手动安装 Alpine 等操作
+- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
+
+> [!TIP]
+>
+> 虽然运行的脚本叫 `reinstall`,但是此功能**不会**删除任何数据和进行自动重装,而是要用户手动操作
+>
+> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
```bash
-bash reinstall.sh alpine --hold=1
+bash reinstall.sh alpine --hold 1
```
#### 可选参数
- `--password PASSWORD` 设置密码
- `--ssh-port PORT` 修改 SSH 端口
+- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--ssh-key)。当使用公钥时,密码为空
+- `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
### 功能 4: 重启到
netboot.xyz
- 可使用商家后台 VNC 手动安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
-- 如果手动操作没有破坏原系统,再次重启将回到原系统
+
+> [!TIP]
+>
+> 虽然运行的脚本叫 `reinstall`,但是此功能**不会**删除任何数据和进行自动重装,而是要用户手动操作
+>
+> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
```bash
bash reinstall.sh netboot.xyz
@@ -244,10 +300,17 @@ bash reinstall.sh netboot.xyz

-- 用户名 `administrator` 默认密码 `123@@@`
+> [!CAUTION]
+>
+> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
+>
+> 数据无价,请三思而后行!
+
+- 用户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效
-- 支持所有语言
+- 支持任意语言的 ISO
+- 支持绕过 Windows 11 硬件限制
#### 支持的系统
@@ -256,12 +319,9 @@ bash reinstall.sh netboot.xyz
- Windows Server Essentials \*
- Windows Server (Semi) Annual Channel \*
- Hyper-V Server \*
- - Azure Stack HCI \*
+ - Azure Local (Azure Stack HCI) \*
-#### ~~方法 1: 让脚本自动查找 ISO~~
-
-> [!CAUTION]
-> 目前该 ISO 仓库禁止了直链下载,因此该方法已失效
+#### 方法 1: 让脚本自动查找 ISO
- 脚本会从 查找 ISO,该网站专门提供官方 ISO 下载
- 上面带 \* 的系统不支持自动查找 ISO
@@ -325,7 +385,7 @@ zh-tw
```bash
bash reinstall.sh windows \
- --image-name "Windows 11 Enterprise LTSC 2024" \
+ --image-name "Windows 11 Enterprise LTSC 2024 Evaluation" \
--iso "https://go.microsoft.com/fwlink/?linkid=2289029"
```
@@ -350,7 +410,6 @@ bash reinstall.sh windows \
-
-
- 评估版
- -
-
-
-
@@ -369,25 +428,53 @@ bash reinstall.sh windows \
- `--password PASSWORD` 设置密码
- `--allow-ping` 设置 Windows 防火墙允许被 Ping
- `--rdp-port PORT` 更改 RDP 端口
-- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
-- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
+- `--ssh-port PORT` 修改 SSH 端口(仅安装期间观察日志用)
+- `--web-port PORT` 修改 Web 端口(仅安装期间观察日志用)
- `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹
- - 需先下载驱动到本地
+ - 需先下载驱动到当前系统
- 可多次设置该参数以添加不同的驱动
-- `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os`
+- `--frpc-toml PATH` 添加 frpc 内网穿透,参数填本地路径或 HTTP 链接
+- `--hold 1` 仅重启到安装环境,不运行安装,用于 SSH 登录验证网络连通性
+- `--hold 2` 用于在进入 Windows 官方安装程序之前,SSH 登录修改 `boot.wim`、`install.wim` 或者其它内容,硬盘挂载在 `/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))
+- VirtIO ([社区版][virtio-virtio], [阿里云][virtio-aliyun], [腾讯云][virtio-qcloud], [GCP][virtio-gcp])
+- XEN ([~~社区版~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws])
+- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
+- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
+- Azure ([MANA 网卡][azure-mana])
+- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7], [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-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
+[virtio-qcloud]: https://cloud.tencent.com/document/product/213/17815#b84b2032-752c-43c4-a509-73530b8f82ff
+[virtio-gcp]: https://console.cloud.google.com/storage/browser/gce-windows-drivers-public
+[xen-xen]: https://xenproject.org/resources/downloads/
+[xen-aws]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/xen-drivers-overview.html
+[xen-citrix]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade
+[aws-ena]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ena-driver-releases-windows.html
+[aws-nvme]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-driver-version-history.html
+[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
+[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
+[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
+[intel-vmd]: https://www.intel.com/content/www/us/en/download/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-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-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
+[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
+[intel-nic-2008-r2]: 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-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
+[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
+[intel-nic-2019]: https://www.intel.com/content/www/us/en/download/19372/intel-network-adapter-driver-for-windows-server-2019.html
+[intel-nic-2022]: https://www.intel.com/content/www/us/en/download/706171/intel-network-adapter-driver-for-windows-server-2022.html
+[intel-nic-2025]: https://www.intel.com/content/www/us/en/download/838943/intel-network-adapter-driver-for-windows-server-2025.html
#### 如何填写映像名称 `--image-name`
-通常一个 ISO 会包含多个系统版本,例如家庭版、专业版。映像名称 `--image-name` 就是用来指定要安装的版本,填写时不区分大小写
+一个 ISO 通常包含多个系统版本,例如家庭版、专业版。因此需要用 `--image-name` 指定要安装的系统版本(映像名称),不区分大小写
可以用 DISM、DISM++、Wimlib 等工具查询 ISO 包含的映像名称
@@ -410,18 +497,32 @@ Windows Server 2025 SERVERDATACENTER
> Vista (Server 2008) 和 32 位系统可能会缺少驱动
> [!WARNING]
-> 未开启 CSM 的 EFI 机器,无法安装 Windows 7 (Server 2008 R2)
>
-> Hyper-V (Azure) 需选择合适的虚拟机代系
+> 安装 Windows 7 (Server 2008 R2) 时
+>
+> 1. EFI 引导的机器要开启 CSM
+>
+> 2. Hyper-V (Azure) 需选择第 1 代虚拟机
> [!WARNING]
+>
> Windows 10 LTSC 2021 中文版镜像 `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 的 `wsappx` 进程会长期占用 CPU
>
> 解决方法是更新系统补丁,或者手动安装 `VCLibs` 库
+> [!WARNING]
+>
+> 在 GCP 上安装 `2022年5月` 和之后发布的 Windows ISO,在引导 Windows 安装界面 (PE) 时会不断反复重启。解决方法如下,二选一
+>
+> 1. 添加 `--force-boot-mode bios` 参数,脚本将以 `BIOS 引导 + MBR 分区表` 方式安装 Windows
+>
+> (可选) 安装完成后用 `MBR2GPT /convert /allowFullOS` 命令转为 `EFI 引导 + GPT 分区表`
+>
+> 2. 自制 RAW 镜像并通过 DD 安装
+
#### ARM 安装 Windows 的注意事项
-大部分 ARM 机器都支持安装 Windows 11 24H2
+大部分 ARM 机器都支持安装最新版 Windows 11
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
@@ -448,10 +549,33 @@ Windows Server 2025 SERVERDATACENTER
-## 讨论
+## 参数格式
-[](https://github.com/bin456789/reinstall/issues)
-[](https://t.me/reinstall_os)
+### --ssh-key
+
+- `--ssh-key "ssh-rsa ..."`
+- `--ssh-key "ssh-ed25519 ..."`
+- `--ssh-key "ecdsa-sha2-nistp256/384/521 ..."`
+- `--ssh-key http://path/to/public_key`
+- `--ssh-key github:your_username`
+- `--ssh-key gitlab:your_username`
+- `--ssh-key /path/to/public_key`
+- `--ssh-key C:\path\to\public_key`
+
+## 如何使用旧版本
+
+根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug
+
+如果遇到新的 Bug,可以试下旧版本是否正常
+
+从 右侧找到旧版本的 `commit_id`
+
+```bash
+commit_id=xxxxxxx
+curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
+sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
+bash reinstall.sh ...
+```
## 如何修改脚本自用
@@ -461,8 +585,6 @@ Windows Server 2025 SERVERDATACENTER
## 感谢
-[](https://github.com/sponsors/bin456789)
-
感谢以下商家提供白嫖机器
[](https://www.oracle.com/cloud/)
diff --git a/debian.cfg b/debian.cfg
index f61a330..d24aa63 100644
--- a/debian.cfg
+++ b/debian.cfg
@@ -2,14 +2,14 @@
# shellcheck disable=SC1091,SC2148
# https://www.debian.org/releases/stable/amd64/apbs04.zh-cn.html
# https://www.debian.org/releases/stable/example-preseed.txt
-# https://preseed.debian.net/debian-preseed/bookworm/amd64-main-full.txt
+# https://preseed.debian.net/debian-preseed/trixie/amd64-main-full.txt
# 需要留意 kali initrd 自带的 /preseed.cfg
# 下面这行语句无效,因为本行后面有反斜杠,前面有空格(安装器认为不算注释)\
-d-i debian-installer/locale string en_US
+d-i debian-installer/locale string en_US.UTF-8
# B.4.1. 本地化
-d-i debian-installer/locale string en_US
+d-i debian-installer/locale string en_US.UTF-8
d-i keyboard-configuration/xkb-keymap select us
# B.4.2. 网络设置
@@ -25,9 +25,10 @@ d-i mirror/country string manual
# B.4.5. 帐号设置
d-i passwd/make-user boolean false
-# 单纯为了跳过设置,实际上是在 partman/early_command 里设置密码,preseed/early_command 无法设置密码
-d-i passwd/root-password password ''
-d-i passwd/root-password-again password ''
+# 注意如果用 ssh key 后面还要删除密码
+# d-i passwd/root-password password ''
+# d-i passwd/root-password-again password ''
+# d-i passwd/root-password-crypted password ''
# kali 需要下面这行,否则会提示输入用户名
d-i passwd/root-login boolean true
@@ -62,6 +63,9 @@ d-i partman-efi/non_efi_system boolean true
# 选择 true 就一直死循环
d-i partman-basicfilesystems/no_swap boolean false
+# 分区大小计算
+# https://salsa.debian.org/installer-team/partman-base/-/blob/master/lib/base.sh
+
# 最小值 膨胀权重 最大值
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes/atomic?ref_type=heads
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes-amd64-efi/atomic?ref_type=heads
@@ -72,6 +76,7 @@ d-i partman-auto/expert_recipe_efi string efi :: \
1 1 -1 $default_filesystem \
method{ format } format{ } use_filesystem{ } $default_filesystem{ } mountpoint{ / } .
+# 大于 2T 会自动用 gpt
# shellcheck disable=SC1083,SC2086,SC2154
d-i partman-auto/expert_recipe_bios string bios :: \
1 1 1 free \
@@ -95,29 +100,130 @@ d-i pkgsel/upgrade select none
# B.4.11. 安装 bootloader
# 添加 bootx64.efi
-d-i grub2/force_efi_extra_removable boolean true
+d-i grub-installer/force-efi-extra-removable boolean true
# B.4.12. 完成安装
-d-i finish-install/reboot_in_progress note
+# 由下面的 hold 2 设置
+# d-i finish-install/reboot_in_progress note
# B.4.13. 预置其他的软件包
# 其他设置
# d-i anna/standard_modules boolean false
# d-i anna/choose_modules string network-console
-# d-i network-console/password password 123@@@
-# d-i network-console/password-again password 123@@@
+# d-i network-console/password password ''
+# d-i network-console/password-again password ''
# B.5.1. 安装过程中运行用户命令
# 注意所有命令都会合并成一行命令
# 最后的 true; \ 没什么用,只是让 vscode 代码高亮不报错误
+# debian 11+ 才有 websocketd
+
# 有 /cdrom/simple-cdd 才安装 simple-cdd-profiles
# 不然安装时 control 脚本会报错:
# Loading simple-cdd-profiles failed for unknown reasons
+
+# 未下载的组件,无法用 debconf-set,需要用 debconf-set-selections
+
+# https://salsa.debian.org/installer-team/network-console/-/blob/master/debian/network-console.postinst?ref_type=heads
+# https://salsa.debian.org/installer-team/user-setup/-/blob/master/user-setup-apply?ref_type=heads
+
+# 此时还没有配置源,anna-install 会在配置完源后再安装
d-i preseed/early_command string true; \
- if [ -d /cdrom/simple-cdd ]; then anna-install simple-cdd-profiles; fi
+ for str in $(grep -wo "extra_[^ ]*" /proc/cmdline | sed 's/^extra_//'); do eval "$str"; done; \
+
+ di(){ \
+ echo "d-i $*" >/tmp/selections.cfg; \
+ echo "d-i $*" >>/tmp/selections.cfg.all; \
+ debconf-set-selections /tmp/selections.cfg; \
+ rm -f /tmp/selections.cfg; \
+ }; \
+
+ run_as_service_with_screen() { \
+ if ! [ -f /etc/screenrc.bak ]; then \
+ cp /etc/screenrc /etc/screenrc.bak; \
+ fi; \
+ true >/etc/screenrc; \
+ screen sh -c 'while true; do pidof ${1##*/} || "$@"; sleep 5; done' _ "$@"; \
+ cp -f /etc/screenrc.bak /etc/screenrc; \
+ }; \
+
+ if [ "$hold" = 1 ]; then \
+ di auto-install/enable boolean false; \
+ di debconf/priority select low; \
+ di partman/early_command string; \
+ else \
+ { \
+ echo 'Reinstalling...'; \
+ echo 'Option 1. View logs:'; \
+ echo ' tail -fn+1 /var/log/syslog'; \
+ echo 'Option 2. Attach to the installer:'; \
+ echo ' TERM=screen screen -xp1'; \
+ } >>/etc/motd; \
+ mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
+ if command -v websocketd && [ "$mem" -ge 400 ]; then \
+ for _ in {1..10}; do \
+ if wget "$confhome/logviewer.html" -O /tmp/index.html; then \
+ break; \
+ fi; \
+ sleep 5; \
+ done; \
+ if [ -z "$web_port" ]; then \
+ web_port=80; \
+ fi; \
+ run_as_service_with_screen websocketd --port 80 --loglevel=fatal --staticdir=/tmp \
+ sh -c "tail -fn+0 /var/log/syslog | tr '\r' '\n' | grep -Fiv -e password -e token" ; \
+ fi; \
+ fi; \
+
+ if ! [ "$hold" = 2 ]; then \
+ di finish-install/reboot_in_progress note; \
+ fi; \
+
+ if [ -s /configs/ssh_keys ]; then \
+ di passwd/root-password-crypted password "''"; \
+ else \
+ di passwd/root-password-crypted password "$(cat /configs/password-linux-sha512)"; \
+ fi; \
+
+ mkdir -p /etc/ssh; \
+ true >/etc/ssh/sshd_config; \
+ if [ -s /configs/ssh_keys ]; then \
+ (umask 077; mkdir -p /.ssh; cat /configs/ssh_keys >/.ssh/authorized_keys); \
+ else \
+ echo "PermitRootLogin yes" >>/etc/ssh/sshd_config; \
+ fi; \
+ if [ -n "$ssh_port" ] && ! [ "$ssh_port" = 22 ]; then \
+ echo "Port $ssh_port" >>/etc/ssh/sshd_config; \
+ fi; \
+ grep -qs ^root: /etc/shadow || echo "root:$(cat /configs/password-linux-sha512):1:0:99999:7:::" >>/etc/shadow; \
+ grep -qs ^nogroup: /etc/group || echo "nogroup:*:65534:" >>/etc/group; \
+ grep -qs ^sshd: /etc/passwd || echo "sshd:*:100:65534::/run/sshd:/bin/false" >>/etc/passwd; \
+ mkdir -p /run/sshd; \
+ chmod 0755 /run/sshd; \
+ ssh-keygen -A; \
+ run_as_service_with_screen /usr/sbin/sshd -D; \
+
+ if [ -s /configs/frpc.toml ]; then \
+ url=$(sh /get-frpc-url.sh linux); \
+ mkdir -p /usr/local/bin; \
+ mkdir -p /usr/local/etc/frpc; \
+ for _ in {1..10}; do \
+ if wget -O- "$url" | tar xz "*/frpc" -O >/usr/local/bin/frpc; then \
+ break; \
+ fi; \
+ sleep 5; \
+ done; \
+ chmod a+x /usr/local/bin/frpc; \
+ cp /configs/frpc.toml /usr/local/etc/frpc/; \
+ run_as_service_with_screen /usr/local/bin/frpc -c /usr/local/etc/frpc/frpc.toml; \
+ fi; \
+
+ if [ -d /cdrom/simple-cdd ]; then \
+ anna-install simple-cdd-profiles; \
+ fi
# debian 11 initrd 没有 xargs awk
# debian 12 initrd 没有 xargs
@@ -131,10 +237,11 @@ d-i partman/early_command string true; \
true >$postinst; \
swapfile=/target/swapfile; \
- mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$y"; }); \
- mem=$((mem / 1024)); \
+ mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$((y / 1024))"; }); \
swap_size=$((512 - mem)); \
- [ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
+ if [ $swap_size -gt 0 ]; then \
+ echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
+ fi; \
echo "swapoff -a; rm -f $swapfile" >/usr/lib/finish-install.d/95swapoff; \
chmod a+x /usr/lib/finish-install.d/95swapoff; \
@@ -151,18 +258,22 @@ d-i partman/early_command string true; \
eths=$(cd /dev/netconf/ && ls); \
- sh /can_use_cloud_kernel.sh "$xda" $eths || debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
+ if ! sh /can_use_cloud_kernel.sh "$xda" $eths; then \
+ debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
+ fi; \
- [ -d /sys/firmware/efi ] && debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_efi)"; \
- [ -d /sys/firmware/efi ] || debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_bios)"; \
-
- debconf-set passwd/root-password-crypted "$(cat /configs/password-linux-sha512)"; \
+ if [ -d /sys/firmware/efi ]; then \
+ debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_efi)"; \
+ else \
+ debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_bios)"; \
+ fi; \
true >/bin/os-prober
# kali ssh 默认关闭
# 另一种方法处理 cloudcone
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
+# debian 9 tar 不支持 --strip-components
d-i preseed/late_command string true; \
for str in $(grep -wo "extra_[^ ]*" /proc/cmdline | sed 's/^extra_//'); do eval "$str"; done; \
@@ -172,14 +283,29 @@ d-i preseed/late_command string true; \
in-target systemctl enable ssh; \
- echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \
- echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config; \
+ if [ -s /configs/ssh_keys ]; then \
+ (umask 077; mkdir -p /target/root/.ssh; cat /configs/ssh_keys >/target/root/.ssh/authorized_keys); \
+ in-target passwd -d root; \
+ else \
+ echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \
+ echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config; \
+ fi; \
if [ -n "$ssh_port" ] && ! [ "$ssh_port" = 22 ]; then \
echo "Port $ssh_port" >/target/etc/ssh/sshd_config.d/01-change-ssh-port.conf || \
echo "Port $ssh_port" >>/target/etc/ssh/sshd_config; \
fi; \
+ if [ -s /configs/frpc.toml ]; then \
+ mkdir -p /target/usr/local/bin; \
+ mkdir -p /target/usr/local/etc/frpc; \
+ cp /usr/local/bin/frpc /target/usr/local/bin/; \
+ cp /usr/local/etc/frpc/frpc.toml /target/usr/local/etc/frpc/; \
+ chmod a+x /target/usr/local/bin/frpc; \
+ cp /frpc.service /target/etc/systemd/system/; \
+ in-target systemctl enable frpc; \
+ fi; \
+
cp /fix-eth-name.sh /target/; \
cp /fix-eth-name.service /target/etc/systemd/system/; \
in-target systemctl enable fix-eth-name
diff --git a/fix-eth-name.service b/fix-eth-name.service
index 1380c73..39a4cbd 100644
--- a/fix-eth-name.service
+++ b/fix-eth-name.service
@@ -22,6 +22,7 @@ ExecStart=/usr/bin/env bash /fix-eth-name.sh
ExecStart=/usr/bin/env rm -f /fix-eth-name.sh
ExecStart=/usr/bin/env rm -f /etc/systemd/system/fix-eth-name.service
ExecStart=/usr/bin/env rm -f /etc/systemd/system/multi-user.target.wants/fix-eth-name.service
+ExecStart=/usr/bin/env rm -f /lib/systemd/system-preset/01-fix-eth-name.preset
ExecStart=/usr/bin/env rm -f /usr/lib/systemd/system-preset/01-fix-eth-name.preset
[Install]
diff --git a/fix-eth-name.sh b/fix-eth-name.sh
index 09e3b36..959579b 100644
--- a/fix-eth-name.sh
+++ b/fix-eth-name.sh
@@ -7,6 +7,13 @@ 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) 改为正确的网卡名,也适用于以下情况
@@ -41,20 +48,39 @@ retry() {
# 用 systemd-analyze plot >a.svg 发现 sys-subsystem-net-devices-enp3s0.device 也是出现在 NetworkManager 之后
# 因此需要等待网卡出现
get_ethx_by_mac() {
- mac=$(echo "$1" | to_lower)
- retry 10 _get_ethx_by_mac "$mac"
+ retry 10 _get_ethx_by_mac "$@"
}
_get_ethx_by_mac() {
+ mac=$(echo "$1" | to_lower)
+
+ flag=$2
+ if [ -z "$flag" ]; then
+ flag=master
+ fi
+
if true; then
- # 过滤 azure vf (带 master ethx)
- ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
- return
+ if [ "$flag" = master ]; then
+ # master
+ # 过滤 azure vf (带 master ethx)
+ ip -o link | grep -i "$mac" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
+ else
+ # slave
+ # 带 master ethx
+ ip -o link | grep -i "$mac" | grep -w master | awk '{print $2}' | cut -d: -f1 | grep .
+ fi
else
for i in $(cd /sys/class/net && echo *); do
if [ "$(cat "/sys/class/net/$i/address")" = "$mac" ]; then
- echo "$i"
- return
+ if [ $(($(cat "/sys/class/net/$i/flags") & 0x800)) -ne 0 ]; then
+ fact_flag=slave
+ else
+ fact_flag=master
+ fi
+ if [ "$flag" = "$fact_flag" ]; then
+ echo "$i"
+ return
+ fi
fi
done
return 1
@@ -131,6 +157,23 @@ fix_network_manager() {
# 更改文件名
mv "$file" "$proper_file"
+
+ # NM 不会自动忽略 Azure 的 slave 网卡,需手动设置
+ # azure 文档中的方法不够通用,只适合 azure
+ # https://learn.microsoft.com/zh-cn/azure/virtual-network/accelerated-networking-overview
+
+ # 我们采用红帽的方法
+ # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/configuring-networkmanager-to-ignore-certain-devices_configuring-and-managing-networking
+ if slave_ethx=$(get_ethx_by_mac "$mac" slave); then
+ cat >"/etc/NetworkManager/conf.d/99-$slave_ethx-unmanaged.conf" <&1 | grep Location:
+ # Location: https://github.com/fatedier/frp/releases/tag/v0.62.0
+ # Location: https://github.com/fatedier/frp/releases/tag/v0.62.0 [following] # 原版 wget 多了这行
+
+ wget --spider -S https://github.com/fatedier/frp/releases/latest 2>&1 |
+ grep -m1 '^ Location:' | sed 's,.*/tag/v,,'
+ fi
+ fi
+ )
+
+ if [ -z "$version" ]; then
+ echo 'cannot find version'
+ return 1
+ fi
+
+ suffix=$(
+ case "$os_type" in
+ linux) echo tar.gz ;;
+ windows) echo zip ;;
+ esac
+ )
+
+ mirror=$(
+ # nju 没有 win7 用的旧版
+ # github 不支持 ipv6
+ # daocloud 加速不支持 ipv6
+ # jsdelivr 不支持 github releases 文件
+ if is_ipv6_only; then
+ if is_need_old_version; then
+ echo 'NOT_SUPPORT'
+ return 1
+ else
+ echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
+ fi
+ else
+ if is_in_china; then
+ if is_need_old_version; then
+ echo https://files.m.daocloud.io/github.com/fatedier/frp/releases/download
+ else
+ echo https://mirrors.nju.edu.cn/github-release/fatedier/frp
+ fi
+ else
+ echo https://github.com/fatedier/frp/releases/download
+ fi
+ fi
+ )
+
+ arch=$(
+ case "$(uname -m)" in
+ x86_64) echo amd64 ;;
+ aarch64) echo arm64 ;;
+ esac
+ )
+
+ filename=frp_${version}_${os_type}_${arch}.$suffix
+
+ echo "${mirror}/v${version}/${filename}"
+}
+
+get_frpc_url "$@"
diff --git a/initrd-network.sh b/initrd-network.sh
index f4b5a0e..e3b21d7 100644
--- a/initrd-network.sh
+++ b/initrd-network.sh
@@ -1,6 +1,6 @@
#!/bin/ash
# shellcheck shell=dash
-# alpine / debian initrd 共用此脚本
+# alpine/debian initrd 共用此脚本
# accept_ra 接收 RA + 自动配置网关
# autoconf 自动配置地址,依赖 accept_ra
@@ -42,9 +42,9 @@ get_ethx() {
# 2: eth0: mtu 1500 qdisc mq state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff:ff:ff:ff
# 3: eth1: mtu 1500 qdisc mq master eth0 state UP qlen 1000\ link/ether 60:45:bd:21:8a:51 brd ff:ff:ff
if false; then
- ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1
+ ip -o link | grep -i "$mac_addr" | grep -v master | awk '{print $2}' | cut -d: -f1 | grep .
else
- ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1
+ ip -o link | grep -i "$mac_addr" | grep -v master | cut -d' ' -f2 | cut -d: -f1 | grep .
fi
}
@@ -240,11 +240,17 @@ test_connect() {
test_internet() {
for i in $(seq 5); do
echo "Testing Internet Connection. Test $i... "
- if is_need_test_ipv4 && test_connect "$(get_first_ipv4_addr | remove_netmask)" "$ipv4_dns1" >/dev/null 2>&1; then
+ if is_need_test_ipv4 &&
+ current_ipv4_addr="$(get_first_ipv4_addr | remove_netmask)" &&
+ { test_connect "$current_ipv4_addr" "$ipv4_dns1" ||
+ test_connect "$current_ipv4_addr" "$ipv4_dns2"; } >/dev/null 2>&1; then
echo "IPv4 has internet."
ipv4_has_internet=true
fi
- if is_need_test_ipv6 && test_connect "$(get_first_ipv6_addr | remove_netmask)" "$ipv6_dns1" >/dev/null 2>&1; then
+ if is_need_test_ipv6 &&
+ current_ipv6_addr="$(get_first_ipv6_addr | remove_netmask)" &&
+ { test_connect "$current_ipv6_addr" "$ipv6_dns1" ||
+ test_connect "$current_ipv6_addr" "$ipv6_dns2"; } >/dev/null 2>&1; then
echo "IPv6 has internet."
ipv6_has_internet=true
fi
@@ -258,8 +264,11 @@ test_internet() {
flush_ipv4_config() {
ip -4 addr flush scope global dev "$ethx"
ip -4 route flush dev "$ethx"
+ # DHCP 获取的 IP 不是重装前的 IP 时,一并删除 DHCP 获取的 DNS,以防 DNS 无效
+ sed -i "/\./d" /etc/resolv.conf
}
+should_disable_dhcpv4=false
should_disable_accept_ra=false
should_disable_autoconf=false
@@ -272,9 +281,17 @@ flush_ipv6_config() {
fi
ip -6 addr flush scope global dev "$ethx"
ip -6 route flush dev "$ethx"
+ # DHCP 获取的 IP 不是重装前的 IP 时,一并删除 DHCP 获取的 DNS,以防 DNS 无效
+ sed -i "/:/d" /etc/resolv.conf
}
-ethx=$(get_ethx)
+for i in $(seq 20); do
+ if ethx=$(get_ethx); then
+ break
+ fi
+ sleep 1
+done
+
if [ -z "$ethx" ]; then
echo "Not found network card: $mac_addr"
exit
@@ -282,6 +299,9 @@ fi
echo "Configuring $ethx ($mac_addr)..."
+# 不开启 lo 则 frp 无法连接 127.0.0.1 22
+ip link set dev lo up
+
# 开启 ethx
ip link set dev "$ethx" up
sleep 1
@@ -325,8 +345,9 @@ EOF
db_progress INFO netcfg/link_detect_progress
else
# alpine
- # h3c 移动云电脑使用 udhcpc 会重复提示 sending select,无法获得 ipv6,因此使用 dhcpcd
- method=dhcpcd
+ # h3c 移动云电脑使用 udhcpc 会重复提示 sending select,无法获得 ipv6
+ # dhcpcd 会配置租约时间,过期会移除 IP,但我们的没有在后台运行 dhcpcd ,因此用 udhcpc
+ method=udhcpc
case "$method" in
udhcpc)
@@ -355,6 +376,10 @@ else
sleep $DNS_FILE_TIMEOUT # 需要等待写入 dns
dhcpcd -x "$ethx" # 终止
fi
+ # autoconf 和 accept_ra 会被 dhcpcd 自动关闭,因此需要重新打开
+ # 如果没重新打开,重新运行 dhcpcd 命令依然可以正常生成 slaac 地址和路由
+ sysctl -w "net.ipv6.conf.$ethx.autoconf=1"
+ sysctl -w "net.ipv6.conf.$ethx.accept_ra=1"
;;
esac
fi
@@ -373,12 +398,7 @@ done
# 由于还没设置静态ip,所以有条目表示有动态地址
is_have_ipv4_addr && dhcpv4=true || dhcpv4=false
is_have_ipv6_addr && dhcpv6_or_slaac=true || dhcpv6_or_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
+is_have_ipv6_gateway && ra_has_gateway=true || ra_has_gateway=false
# 如果自动获取的 IP 不是重装前的,则改成静态,使用之前的 IP
# 只比较 IP,不比较掩码/网关,因为
@@ -387,13 +407,12 @@ fi
if $dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] &&
! [ "$(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
+ should_disable_dhcpv4=true
flush_ipv4_config
fi
if $dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
! [ "$(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_accept_ra=true
should_disable_autoconf=true
flush_ipv6_config
@@ -413,18 +432,19 @@ test_internet
# IP 不同的情况在前面已经改成静态了
if ! $ipv4_has_internet &&
$dhcpv4 && [ -n "$ipv4_addr" ] && [ -n "$ipv4_gateway" ] &&
- ! { [ "$ipv4_addr" = "$(get_first_ipv4_addr)" ] || [ "$ipv4_gateway" = "$(get_first_ipv4_gateway)" ]; }; then
+ ! { [ "$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
+ should_disable_dhcpv4=true
flush_ipv4_config
add_missing_ipv4_config
test_internet
fi
+# 有可能是静态 IPv6 但能从 RA 获取到网关,因此加上 || $ra_has_gateway
if ! $ipv6_has_internet &&
- $dhcpv6_or_slaac && [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
- ! { [ "$ipv6_addr" = "$(get_first_ipv6_addr)" ] || [ "$ipv6_gateway" = "$(get_first_ipv6_gateway)" ]; }; then
+ { $dhcpv6_or_slaac || $ra_has_gateway; } &&
+ [ -n "$ipv6_addr" ] && [ -n "$ipv6_gateway" ] &&
+ ! { [ "$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_accept_ra=true
should_disable_autoconf=true
flush_ipv6_config
@@ -432,31 +452,41 @@ if ! $ipv6_has_internet &&
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
- flush_ipv6_config
-elif ! $ipv4_has_internet && $ipv6_has_internet; then
+# 2 有ipv4地址但没有ipv4网关的情况(vultr $2.5 ipv6 only),aria2会用ipv4下载
+
+# 假设 ipv4 ipv6 在不同网卡,ipv4 能上网但 ipv6 不能上网,这时也要删除 ipv6
+# 不能用 ipv4_has_internet && ! ipv6_has_internet 判断,因为它判断的是同一个网卡
+if ! $ipv4_has_internet; then
+ if $dhcpv4; then
+ should_disable_dhcpv4=true
+ fi
flush_ipv4_config
fi
+if ! $ipv6_has_internet; then
+ # 防止删除 IPv6 后再次通过 SLAAC 获得
+ # 不用判断 || $ra_has_gateway ,因为没有 IPv6 地址但有 IPv6 网关时,不会出现下载问题
+ if $dhcpv6_or_slaac; then
+ should_disable_accept_ra=true
+ should_disable_autoconf=true
+ fi
+ flush_ipv6_config
+fi
# 如果联网了,但没获取到默认 DNS,则添加我们的 DNS
-if $ipv4_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv4_dns; }; then
+
+# 有一种情况是,多网卡,且能上网的网卡先完成了这个脚本,不能上网的网卡后完成
+# 无法上网的网卡通过 flush_ipv4_config 删除了不能上网的 IP 和 dns
+# (原计划是删除无法上网的网卡 dhcp4 获取的 dns,但实际上无法区分)
+# 因此这里直接添加 dns,不判断是否联网
+if ! is_have_ipv4_dns; then
echo "nameserver $ipv4_dns1" >>/etc/resolv.conf
echo "nameserver $ipv4_dns2" >>/etc/resolv.conf
fi
-if $ipv6_has_internet && ! { [ -e /etc/resolv.conf ] && is_have_ipv6_dns; }; then
+if ! is_have_ipv6_dns; then
echo "nameserver $ipv6_dns1" >>/etc/resolv.conf
echo "nameserver $ipv6_dns2" >>/etc/resolv.conf
fi
@@ -466,6 +496,7 @@ netconf="/dev/netconf/$ethx"
mkdir -p "$netconf"
$dhcpv4 && echo 1 >"$netconf/dhcpv4" || echo 0 >"$netconf/dhcpv4"
$dhcpv6_or_slaac && echo 1 >"$netconf/dhcpv6_or_slaac" || echo 0 >"$netconf/dhcpv6_or_slaac"
+$should_disable_dhcpv4 && echo 1 >"$netconf/should_disable_dhcpv4" || echo 0 >"$netconf/should_disable_dhcpv4"
$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"
diff --git a/logviewer.html b/logviewer.html
index 05c1cea..edd6065 100644
--- a/logviewer.html
+++ b/logviewer.html
@@ -58,7 +58,7 @@