mirror of
https://github.com/bin456789/reinstall.git
synced 2025-10-02 13:04:55 +00:00
Compare commits
9 Commits
df2bda09dc
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1afc1a0022 | ||
![]() |
cdf09d017f | ||
![]() |
8d55af091d | ||
![]() |
8689c45b07 | ||
![]() |
ce8a315a2e | ||
![]() |
cf6b4c226d | ||
![]() |
b098c0cabd | ||
![]() |
2a0690a395 | ||
![]() |
30a3616bf8 |
15
.github/ISSUE_TEMPLATE/bug_report.md
vendored
15
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -7,10 +7,13 @@ assignees: ''
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
原来的系统:
|
原来的系统 (Original system):
|
||||||
要安装的系统:
|
|
||||||
遇到的问题:截图或者登录 SSH 获取日志 /reinstall.log
|
|
||||||
|
|
||||||
Original system:
|
要安装的系统 (System to be installed):
|
||||||
System to be installed:
|
|
||||||
Issues encountered: Screenshot or log in via SSH to get the logs from /reinstall.log
|
遇到的问题 (Issue):
|
||||||
|
|
||||||
|
<!--
|
||||||
|
请上传截图或者报错内容,注意删除 IP 地址和密码
|
||||||
|
(Please Upload Screenshot or error message. Be sure to delete the IP address and password)
|
||||||
|
-->
|
||||||
|
19
.github/workflows/run_reinstall.yml
vendored
19
.github/workflows/run_reinstall.yml
vendored
@@ -21,18 +21,19 @@ jobs:
|
|||||||
git config --global core.autocrlf false
|
git config --global core.autocrlf false
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: |
|
- run: |
|
||||||
${{ matrix.command }} centos
|
# ${{ matrix.command }} centos
|
||||||
${{ matrix.command }} almalinux 8
|
${{ matrix.command }} almalinux
|
||||||
${{ matrix.command }} rocky 9
|
# ${{ matrix.command }} rocky
|
||||||
${{ matrix.command }} fedora
|
# ${{ matrix.command }} fedora
|
||||||
|
# ${{ matrix.command }} oracle
|
||||||
${{ matrix.command }} ubuntu
|
${{ matrix.command }} ubuntu
|
||||||
${{ matrix.command }} debian
|
${{ matrix.command }} debian
|
||||||
${{ matrix.command }} debian --ci
|
${{ matrix.command }} debian --ci
|
||||||
${{ matrix.command }} kali
|
# ${{ matrix.command }} kali
|
||||||
${{ matrix.command }} alpine
|
# ${{ matrix.command }} alpine
|
||||||
${{ matrix.command }} opensuse
|
# ${{ matrix.command }} opensuse
|
||||||
${{ matrix.command }} arch
|
# ${{ matrix.command }} arch
|
||||||
${{ matrix.command }} gentoo
|
# ${{ matrix.command }} gentoo
|
||||||
|
|
||||||
${{ 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
|
||||||
|
144
README.en.md
144
README.en.md
@@ -5,24 +5,39 @@
|
|||||||
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
||||||
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||||
[](https://github.com/XAMPPRocky/tokei_rs)
|
[](https://github.com/XAMPPRocky/tokei_rs)
|
||||||
[](https://t.me/reinstall_os)
|
|
||||||
[](https://github.com/sponsors/bin456789)
|
|
||||||
|
|
||||||
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 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`.
|
||||||
- One-click Linux installation: Supports 19 common distributions.
|
- Supports reinstallation in any direction, i.e., `Linux to Linux`, `Linux to Windows`, `Windows to Windows`, `Windows to Linux`
|
||||||
- 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`.
|
- Automatically configures IP and intelligently sets it as static or dynamic. Supports `/32`, `/128`, `gateway outside subnet`, `IPv6 only`, `IPv4/IPv6 on different NIC`
|
||||||
- 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`
|
|
||||||
- Specially optimized for low-spec servers, requires less memory than the official netboot
|
- 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
|
- 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
|
- Supports BIOS and EFI boot, and ARM Server
|
||||||
- No homemades image included, all resources are obtained in real-time from mirror sites
|
- 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
|
## System Requirements
|
||||||
|
|
||||||
The original system can be any system listed in the table.
|
The original system can be any system listed in the table.
|
||||||
@@ -36,11 +51,11 @@ The system requirements for the target system are as follows:
|
|||||||
| <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 | 16.04 LTS - 24.04 LTS, 25.04 | 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.04 | 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 <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 (if released) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 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 | 41, 42 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 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 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 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 |
|
||||||
@@ -56,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
|
^ Indicates requiring either 256 MB memory + 1.5 GB disk, or 512 MB memory + 1 GB disk
|
||||||
|
|
||||||
> [!WARNING]
|
> [!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.
|
> ❌ This script does not support OpenVZ or LXC virtual machines.
|
||||||
>
|
>
|
||||||
> Please use <https://github.com/LloydAsp/OsMutation> instead.
|
> Please use <https://github.com/LloydAsp/OsMutation> instead.
|
||||||
@@ -65,13 +87,13 @@ The system requirements for the target system are as follows:
|
|||||||
For server outside China:
|
For server outside China:
|
||||||
|
|
||||||
```bash
|
```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:
|
For server inside China:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -O https://cnb.cool/bin456789/reinstall/-/git/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 <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
## Download (Current system is <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
||||||
@@ -117,6 +139,12 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
|||||||
|
|
||||||
### Feature 1: Install <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
### Feature 1: Install <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
>
|
||||||
|
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||||
|
>
|
||||||
|
> Data is priceless — please think twice before proceeding!
|
||||||
|
|
||||||
- The username is `root` with a default password of `123@@@`.
|
- The username is `root` with a default password of `123@@@`.
|
||||||
- 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 usage: no boot partition (except for Fedora) and no swap partition.
|
- Maximizes disk space usage: no boot partition (except for Fedora) and no swap partition.
|
||||||
@@ -127,7 +155,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
|||||||
```bash
|
```bash
|
||||||
bash reinstall.sh anolis 7|8|23
|
bash reinstall.sh anolis 7|8|23
|
||||||
rocky 8|9|10
|
rocky 8|9|10
|
||||||
oracle 8|9
|
oracle 8|9|10
|
||||||
almalinux 8|9|10
|
almalinux 8|9|10
|
||||||
opencloudos 8|9|23
|
opencloudos 8|9|23
|
||||||
centos 9|10
|
centos 9|10
|
||||||
@@ -136,7 +164,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
debian 9|10|11|12|13
|
debian 9|10|11|12|13
|
||||||
opensuse 15.6|tumbleweed
|
opensuse 15.6|tumbleweed
|
||||||
alpine 3.19|3.20|3.21|3.22
|
alpine 3.19|3.20|3.21|3.22
|
||||||
openeuler 20.03|22.03|24.03|25.03
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||||
kali
|
kali
|
||||||
arch
|
arch
|
||||||
@@ -149,17 +177,9 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
#### Optional Parameters
|
#### Optional Parameters
|
||||||
|
|
||||||
- `--password PASSWORD` Set the password
|
- `--password PASSWORD` Set the password
|
||||||
- `--ssh-key KEY` Set up SSH login public key, supports these formats. 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-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`
|
|
||||||
- `--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)
|
- `--web-port PORT` Change the Web port (for log observation during installation only)
|
||||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
||||||
- `--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).
|
- `--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).
|
||||||
|
|
||||||
@@ -201,7 +221,13 @@ bash reinstall.sh ubuntu --installer
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### Feature 2: DD
|
### Feature 2: DD RAW image to hard disk
|
||||||
|
|
||||||
|
> [!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 `vhd` image formats (either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`).
|
- Supports `raw` and `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.
|
||||||
@@ -226,9 +252,14 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
|||||||
|
|
||||||
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS (RAM OS)
|
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> 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.
|
- You can use SSH to backup/restore disk, manually perform DD operations, partition modifications, manual Alpine installation, and other operations.
|
||||||
- Username `root`, Default password `123@@@`
|
- Username `root`, Default password `123@@@`
|
||||||
- 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
|
||||||
bash reinstall.sh alpine --hold=1
|
bash reinstall.sh alpine --hold=1
|
||||||
@@ -238,21 +269,18 @@ 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, supports these formats. 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-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`
|
|
||||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
||||||
|
|
||||||
### 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
|
||||||
|
|
||||||
- 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.
|
- 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
|
||||||
bash reinstall.sh netboot.xyz
|
bash reinstall.sh netboot.xyz
|
||||||
@@ -264,6 +292,12 @@ bash reinstall.sh netboot.xyz
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
> [!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`, Default password `123@@@`
|
- Username `administrator`, Default password `123@@@`
|
||||||
- If remote login fails, try using the username `.\administrator`.
|
- 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.
|
- The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot.
|
||||||
@@ -276,7 +310,7 @@ bash reinstall.sh netboot.xyz
|
|||||||
- Windows Server Essentials \*
|
- Windows Server Essentials \*
|
||||||
- Windows Server (Semi) Annual Channel \*
|
- Windows Server (Semi) Annual Channel \*
|
||||||
- Hyper-V Server \*
|
- Hyper-V Server \*
|
||||||
- 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
|
||||||
|
|
||||||
@@ -386,18 +420,18 @@ bash reinstall.sh windows \
|
|||||||
- `--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
|
||||||
- `--ssh-port PORT` Change SSH 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)
|
- `--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.
|
- `--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.
|
- This parameter can be set multiple times to add different driver.
|
||||||
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
- `--frpc-toml /path/to/frpc.toml` Add frpc for intranet tunneling
|
||||||
- `--hold 2` Allow SSH connections for modifying the disk content before rebooting into the official Windows installation program, with the disk mounted at `/os`.
|
- `--hold 2` Allow SSH connections for modifying the disk content before rebooting into the official Windows installation program, with the disk mounted at `/os`.
|
||||||
|
|
||||||
#### The following drivers will automatic download and install as needed, without the need for manual addition
|
#### The following drivers will automatic download and install as needed, without the need for manual addition
|
||||||
|
|
||||||
- Virtio ([Virtio][virtio-virtio], [Alibaba Cloud][virtio-aliyun], [Tencent Cloud][virtio-qcloud], [GCP][virtio-gcp])
|
- VirtIO ([Community][virtio-virtio], [Alibaba Cloud][virtio-aliyun], [Tencent Cloud][virtio-qcloud], [GCP][virtio-gcp])
|
||||||
- XEN ([~~XEN~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws])
|
- XEN ([~~Community~~][xen-xen] (unsigned), [Citrix][xen-citrix], [AWS][xen-aws])
|
||||||
- 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])
|
||||||
@@ -421,7 +455,7 @@ bash reinstall.sh windows \
|
|||||||
[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://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.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
|
||||||
@@ -431,7 +465,7 @@ bash reinstall.sh windows \
|
|||||||
|
|
||||||
#### How to Specify the Image Name `--image-name`
|
#### 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.
|
You can use tools like DISM, DISM++, or Wimlib to query the image names included in the ISO.
|
||||||
|
|
||||||
@@ -492,10 +526,18 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Discussion
|
## Parameter Format
|
||||||
|
|
||||||
[](https://github.com/bin456789/reinstall/issues)
|
### --ssh-key
|
||||||
[](https://t.me/reinstall_os)
|
|
||||||
|
- `--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 Modify the Script for Your Own
|
## How to Modify the Script for Your Own
|
||||||
|
|
||||||
@@ -505,8 +547,6 @@ Log in to the server using Remote Desktop, open Device Manager, locate the graph
|
|||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
|
|
||||||
[](https://github.com/sponsors/bin456789)
|
|
||||||
|
|
||||||
Thanks to the following businesses for providing free servers.
|
Thanks to the following businesses for providing free servers.
|
||||||
|
|
||||||
[](https://www.oracle.com/cloud/)
|
[](https://www.oracle.com/cloud/)
|
||||||
|
142
README.md
142
README.md
@@ -5,24 +5,39 @@
|
|||||||
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
[](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
|
||||||
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
[](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||||
[](https://github.com/XAMPPRocky/tokei_rs)
|
[](https://github.com/XAMPPRocky/tokei_rs)
|
||||||
[](https://t.me/reinstall_os)
|
|
||||||
[](https://github.com/sponsors/bin456789)
|
|
||||||
|
|
||||||
一键重装脚本 [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`
|
- 支持任意方向重装,即 `Linux to Linux`、`Linux to Windows`、`Windows to Windows`、`Windows to Linux`
|
||||||
- 无需填写 IP 参数,自动识别动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`双网卡`
|
- 自动设置 IP,智能设置动静态,支持 `/32`、`/128`、`网关不在子网范围内`、`纯 IPv6`、`IPv4/IPv6 在不同的网卡`
|
||||||
- 专门适配低配小鸡,比官方 netboot 需要更少的内存
|
- 专门适配低配小鸡,比官方 netboot 需要更少的内存
|
||||||
- 全程用分区表 ID 识别硬盘,确保不会写错硬盘
|
- 全程用分区表 ID 识别硬盘,确保不会写错硬盘
|
||||||
- 支持 BIOS、EFI 引导,支持 ARM 服务器
|
- 支持 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)
|
||||||
|
|
||||||
## 系统要求
|
## 系统要求
|
||||||
|
|
||||||
原系统可以是表格中的任意系统
|
原系统可以是表格中的任意系统
|
||||||
@@ -36,11 +51,11 @@
|
|||||||
| <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 | 16.04 LTS - 24.04 LTS, 25.04 | 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.04 | 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 <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 (如果有) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 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 | 41, 42 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 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 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 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 |
|
||||||
@@ -56,6 +71,13 @@
|
|||||||
^ 表示需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
|
^ 表示需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
|
||||||
|
|
||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
|
>
|
||||||
|
> 本脚本理论上支持独服和 PC
|
||||||
|
>
|
||||||
|
> 但如果能使用 IPMI 或 U 盘,则不建议使用本脚本
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
>
|
||||||
> ❌ 本脚本不支持 OpenVZ、LXC 虚拟机
|
> ❌ 本脚本不支持 OpenVZ、LXC 虚拟机
|
||||||
>
|
>
|
||||||
> 请改用 <https://github.com/LloydAsp/OsMutation>
|
> 请改用 <https://github.com/LloydAsp/OsMutation>
|
||||||
@@ -65,13 +87,13 @@
|
|||||||
国外服务器:
|
国外服务器:
|
||||||
|
|
||||||
```bash
|
```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
|
```bash
|
||||||
curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O reinstall.sh $_
|
curl -O https://cnb.cool/bin456789/reinstall/-/git/raw/main/reinstall.sh || wget -O ${_##*/} $_
|
||||||
```
|
```
|
||||||
|
|
||||||
## 下载(当前系统是 <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
## 下载(当前系统是 <img width="20" height="20" src="https://blogs.windows.com/wp-content/uploads/prod/2022/09/cropped-Windows11IconTransparent512-32x32.png" /> Windows)
|
||||||
@@ -113,10 +135,16 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
|||||||
|
|
||||||
- Linux 下运行 `bash reinstall.sh ...`
|
- Linux 下运行 `bash reinstall.sh ...`
|
||||||
- Windows 下先运行 `cmd`,再运行 `reinstall.bat ...`
|
- Windows 下先运行 `cmd`,再运行 `reinstall.bat ...`
|
||||||
- 如果参数中的链接包含特殊字符,要用 `""` 将链接包起来,不能用 `''`
|
- 如果参数中的链接包含特殊字符,要用 `""` 将链接包裹起来,不能用 `''`
|
||||||
|
|
||||||
### 功能 1: 安装 <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
### 功能 1: 安装 <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
>
|
||||||
|
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||||
|
>
|
||||||
|
> 数据无价,请三思而后行!
|
||||||
|
|
||||||
- 用户名 `root` 默认密码 `123@@@`
|
- 用户名 `root` 默认密码 `123@@@`
|
||||||
- 安装最新版可不输入版本号
|
- 安装最新版可不输入版本号
|
||||||
- 最大化利用磁盘空间:不含 boot 分区(Fedora 例外),不含 swap 分区
|
- 最大化利用磁盘空间:不含 boot 分区(Fedora 例外),不含 swap 分区
|
||||||
@@ -127,7 +155,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
|||||||
```bash
|
```bash
|
||||||
bash reinstall.sh anolis 7|8|23
|
bash reinstall.sh anolis 7|8|23
|
||||||
rocky 8|9|10
|
rocky 8|9|10
|
||||||
oracle 8|9
|
oracle 8|9|10
|
||||||
almalinux 8|9|10
|
almalinux 8|9|10
|
||||||
opencloudos 8|9|23
|
opencloudos 8|9|23
|
||||||
centos 9|10
|
centos 9|10
|
||||||
@@ -136,7 +164,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
debian 9|10|11|12|13
|
debian 9|10|11|12|13
|
||||||
opensuse 15.6|tumbleweed
|
opensuse 15.6|tumbleweed
|
||||||
alpine 3.19|3.20|3.21|3.22
|
alpine 3.19|3.20|3.21|3.22
|
||||||
openeuler 20.03|22.03|24.03|25.03
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||||
kali
|
kali
|
||||||
arch
|
arch
|
||||||
@@ -149,15 +177,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
#### 可选参数
|
#### 可选参数
|
||||||
|
|
||||||
- `--password PASSWORD` 设置密码
|
- `--password PASSWORD` 设置密码
|
||||||
- `--ssh-key KEY` 设置 SSH 登录公钥,支持以下格式。当使用公钥时,密码为空
|
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--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`
|
|
||||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统)
|
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用,也作用于新系统)
|
||||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
||||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
||||||
@@ -201,7 +221,13 @@ bash reinstall.sh ubuntu --installer
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### 功能 2: DD
|
### 功能 2: DD RAW 镜像到硬盘
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
>
|
||||||
|
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||||
|
>
|
||||||
|
> 数据无价,请三思而后行!
|
||||||
|
|
||||||
- 支持 `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,可能首次开机几分钟后才生效
|
||||||
@@ -226,9 +252,14 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
|||||||
|
|
||||||
### 功能 3: 重启到 <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS(内存系统)
|
### 功能 3: 重启到 <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS(内存系统)
|
||||||
|
|
||||||
- 可用 ssh 连接,进行备份/恢复硬盘、手动 DD、修改分区、手动安装 Alpine/Arch/Gentoo 等操作
|
- 可用 ssh 连接,进行备份/恢复硬盘、手动 DD、修改分区、手动安装 Alpine 等操作
|
||||||
- 用户名 `root` 默认密码 `123@@@`
|
- 用户名 `root` 默认密码 `123@@@`
|
||||||
- 如果手动操作没有破坏原系统,再次重启将回到原系统
|
|
||||||
|
> [!TIP]
|
||||||
|
>
|
||||||
|
> 虽然运行的脚本叫 `reinstall`,但是此功能**不会**删除任何数据和进行自动重装,而是要用户手动操作
|
||||||
|
>
|
||||||
|
> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash reinstall.sh alpine --hold=1
|
bash reinstall.sh alpine --hold=1
|
||||||
@@ -238,21 +269,18 @@ bash reinstall.sh alpine --hold=1
|
|||||||
|
|
||||||
- `--password PASSWORD` 设置密码
|
- `--password PASSWORD` 设置密码
|
||||||
- `--ssh-port PORT` 修改 SSH 端口
|
- `--ssh-port PORT` 修改 SSH 端口
|
||||||
- `--ssh-key KEY` 设置 SSH 登录公钥,支持以下格式。当使用公钥时,密码为空
|
- `--ssh-key KEY` 设置 SSH 登录公钥,[格式如下](#--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`
|
|
||||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
||||||
|
|
||||||
### 功能 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
|
||||||
|
|
||||||
- 可使用商家后台 VNC 手动安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
|
- 可使用商家后台 VNC 手动安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
|
||||||
- 如果手动操作没有破坏原系统,再次重启将回到原系统
|
|
||||||
|
> [!TIP]
|
||||||
|
>
|
||||||
|
> 虽然运行的脚本叫 `reinstall`,但是此功能**不会**删除任何数据和进行自动重装,而是要用户手动操作
|
||||||
|
>
|
||||||
|
> 如果用户手动操作没有破坏原系统,再次重启将回到原系统
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash reinstall.sh netboot.xyz
|
bash reinstall.sh netboot.xyz
|
||||||
@@ -264,6 +292,12 @@ bash reinstall.sh netboot.xyz
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
>
|
||||||
|
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||||
|
>
|
||||||
|
> 数据无价,请三思而后行!
|
||||||
|
|
||||||
- 用户名 `administrator` 默认密码 `123@@@`
|
- 用户名 `administrator` 默认密码 `123@@@`
|
||||||
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
||||||
- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效
|
- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效
|
||||||
@@ -276,7 +310,7 @@ bash reinstall.sh netboot.xyz
|
|||||||
- Windows Server Essentials \*
|
- Windows Server Essentials \*
|
||||||
- Windows Server (Semi) Annual Channel \*
|
- Windows Server (Semi) Annual Channel \*
|
||||||
- Hyper-V Server \*
|
- Hyper-V Server \*
|
||||||
- Azure Stack HCI \*
|
- Azure Local (Azure Stack HCI) \*
|
||||||
|
|
||||||
#### 方法 1: 让脚本自动查找 ISO
|
#### 方法 1: 让脚本自动查找 ISO
|
||||||
|
|
||||||
@@ -386,18 +420,18 @@ bash reinstall.sh windows \
|
|||||||
- `--password PASSWORD` 设置密码
|
- `--password PASSWORD` 设置密码
|
||||||
- `--allow-ping` 设置 Windows 防火墙允许被 Ping
|
- `--allow-ping` 设置 Windows 防火墙允许被 Ping
|
||||||
- `--rdp-port PORT` 更改 RDP 端口
|
- `--rdp-port PORT` 更改 RDP 端口
|
||||||
- `--ssh-port PORT` 修改 SSH 端口(安装期间观察日志用)
|
- `--ssh-port PORT` 修改 SSH 端口(仅安装期间观察日志用)
|
||||||
- `--web-port PORT` 修改 Web 端口(安装期间观察日志用)
|
- `--web-port PORT` 修改 Web 端口(仅安装期间观察日志用)
|
||||||
- `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹
|
- `--add-driver INF_OR_DIR` 添加额外驱动,填写 .inf 路径,或者 .inf 所在的文件夹
|
||||||
- 需先下载驱动到本地
|
- 需先下载驱动到当前系统
|
||||||
- 可多次设置该参数以添加不同的驱动
|
- 可多次设置该参数以添加不同的驱动
|
||||||
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
- `--frpc-toml /path/to/frpc.toml` 添加 frpc 内网穿透
|
||||||
- `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os`
|
- `--hold 2` 在进入 Windows 官方安装程序之前,可以 SSH 登录修改硬盘内容,硬盘挂载在 `/os`
|
||||||
|
|
||||||
#### 以下驱动会自动按需下载安装,无需手动添加
|
#### 以下驱动会自动按需下载安装,无需手动添加
|
||||||
|
|
||||||
- Virtio ([Virtio][virtio-virtio], [阿里云][virtio-aliyun], [腾讯云][virtio-qcloud], [GCP][virtio-gcp])
|
- VirtIO ([社区版][virtio-virtio], [阿里云][virtio-aliyun], [腾讯云][virtio-qcloud], [GCP][virtio-gcp])
|
||||||
- XEN ([~~XEN~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws])
|
- XEN ([~~社区版~~][xen-xen] (未签名), [Citrix][xen-citrix], [AWS][xen-aws])
|
||||||
- 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])
|
||||||
@@ -421,7 +455,7 @@ bash reinstall.sh windows \
|
|||||||
[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://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.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
|
||||||
@@ -431,7 +465,7 @@ bash reinstall.sh windows \
|
|||||||
|
|
||||||
#### 如何填写映像名称 `--image-name`
|
#### 如何填写映像名称 `--image-name`
|
||||||
|
|
||||||
通常一个 ISO 会包含多个系统版本,例如家庭版、专业版。映像名称 `--image-name` 就是用来指定要安装的版本,填写时不区分大小写
|
一个 ISO 通常包含多个系统版本,例如家庭版、专业版。因此需要用 `--image-name` 指定要安装的系统版本(映像名称),不区分大小写
|
||||||
|
|
||||||
可以用 DISM、DISM++、Wimlib 等工具查询 ISO 包含的映像名称
|
可以用 DISM、DISM++、Wimlib 等工具查询 ISO 包含的映像名称
|
||||||
|
|
||||||
@@ -492,10 +526,18 @@ Windows Server 2025 SERVERDATACENTER
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## 讨论
|
## 参数格式
|
||||||
|
|
||||||
[](https://github.com/bin456789/reinstall/issues)
|
### --ssh-key
|
||||||
[](https://t.me/reinstall_os)
|
|
||||||
|
- `--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`
|
||||||
|
|
||||||
## 如何修改脚本自用
|
## 如何修改脚本自用
|
||||||
|
|
||||||
@@ -505,8 +547,6 @@ Windows Server 2025 SERVERDATACENTER
|
|||||||
|
|
||||||
## 感谢
|
## 感谢
|
||||||
|
|
||||||
[](https://github.com/sponsors/bin456789)
|
|
||||||
|
|
||||||
感谢以下商家提供白嫖机器
|
感谢以下商家提供白嫖机器
|
||||||
|
|
||||||
[](https://www.oracle.com/cloud/)
|
[](https://www.oracle.com/cloud/)
|
||||||
|
@@ -369,6 +369,10 @@ else
|
|||||||
sleep $DNS_FILE_TIMEOUT # 需要等待写入 dns
|
sleep $DNS_FILE_TIMEOUT # 需要等待写入 dns
|
||||||
dhcpcd -x "$ethx" # 终止
|
dhcpcd -x "$ethx" # 终止
|
||||||
fi
|
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
|
esac
|
||||||
fi
|
fi
|
||||||
|
42
reinstall.sh
42
reinstall.sh
@@ -48,7 +48,7 @@ usage_and_exit() {
|
|||||||
Usage: $reinstall_____ anolis 7|8|23
|
Usage: $reinstall_____ anolis 7|8|23
|
||||||
opencloudos 8|9|23
|
opencloudos 8|9|23
|
||||||
rocky 8|9|10
|
rocky 8|9|10
|
||||||
oracle 8|9
|
oracle 8|9|10
|
||||||
almalinux 8|9|10
|
almalinux 8|9|10
|
||||||
centos 9|10
|
centos 9|10
|
||||||
fedora 41|42
|
fedora 41|42
|
||||||
@@ -56,7 +56,7 @@ Usage: $reinstall_____ anolis 7|8|23
|
|||||||
debian 9|10|11|12|13
|
debian 9|10|11|12|13
|
||||||
opensuse 15.6|tumbleweed
|
opensuse 15.6|tumbleweed
|
||||||
alpine 3.19|3.20|3.21|3.22
|
alpine 3.19|3.20|3.21|3.22
|
||||||
openeuler 20.03|22.03|24.03|25.03
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||||
kali
|
kali
|
||||||
arch
|
arch
|
||||||
@@ -865,6 +865,7 @@ get_windows_iso_link() {
|
|||||||
serverdatacenter | serverdatacentercore) echo _ ;;
|
serverdatacenter | serverdatacentercore) echo _ ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
# massgrave 不提供 2012 下载
|
||||||
'2012 r2' | \
|
'2012 r2' | \
|
||||||
2016 | 2019 | 2022 | 2025)
|
2016 | 2019 | 2022 | 2025)
|
||||||
case "$edition" in
|
case "$edition" in
|
||||||
@@ -889,13 +890,25 @@ get_windows_iso_link() {
|
|||||||
case "$edition" in
|
case "$edition" in
|
||||||
starter)
|
starter)
|
||||||
case "$arch_win" in
|
case "$arch_win" in
|
||||||
x86) echo ultimate ;;
|
x86) echo starter ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
homebasic | homepremium | professional | ultimate) echo ultimate ;;
|
homebasic)
|
||||||
|
case "$arch_win" in
|
||||||
|
x86) echo "home basic" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
homepremium) echo "home premium" ;;
|
||||||
|
professional | enterprise | ultimate) echo "$edition" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
# massgrave 不提供 windows 8 下载
|
||||||
|
8.1)
|
||||||
|
case "$edition" in
|
||||||
|
'') echo _ ;; # windows 8.1 core
|
||||||
|
pro | enterprise) echo "$edition" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
# 8.1 需到 msdl.gravesoft.dev 下载
|
|
||||||
10)
|
10)
|
||||||
case "$edition" in
|
case "$edition" in
|
||||||
home | 'home single language') echo consumer ;;
|
home | 'home single language') echo consumer ;;
|
||||||
@@ -947,6 +960,8 @@ get_windows_iso_link() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 8.1 和 11 arm 没有每月发布 iso
|
||||||
|
# 因此优先从 msdl 下载
|
||||||
get_label_msdl() {
|
get_label_msdl() {
|
||||||
case "$version" in
|
case "$version" in
|
||||||
8.1)
|
8.1)
|
||||||
@@ -992,12 +1007,13 @@ get_windows_iso_link() {
|
|||||||
label_vlsc=$(get_label_vlsc)
|
label_vlsc=$(get_label_vlsc)
|
||||||
page=$(get_page)
|
page=$(get_page)
|
||||||
|
|
||||||
if [ "$page" = server ]; then
|
if [ "$page" = vista ]; then
|
||||||
delimiter=-
|
page_url=https://massgrave.dev/windows_vista__links
|
||||||
|
elif [ "$page" = server ]; then
|
||||||
|
page_url=https://massgrave.dev/windows-server-links
|
||||||
else
|
else
|
||||||
delimiter=_
|
page_url=https://massgrave.dev/windows_${page}_links
|
||||||
fi
|
fi
|
||||||
page_url=https://massgrave.dev/windows${delimiter}${page}${delimiter}links
|
|
||||||
|
|
||||||
info "Find windows iso"
|
info "Find windows iso"
|
||||||
echo "Version: $version"
|
echo "Version: $version"
|
||||||
@@ -1613,7 +1629,9 @@ Continue with DD?
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
elarch=$basearch
|
elarch=$basearch
|
||||||
if [ "$distro" = almalinux ] && [ "$basearch" = x86_64 ] && ! is_cpu_supports_x86_64_v3; then
|
if [ "$basearch" = x86_64 ] &&
|
||||||
|
[ "$distro" = almalinux ] && [ "$releasever" -ge 10 ] &&
|
||||||
|
! is_cpu_supports_x86_64_v3; then
|
||||||
elarch=x86_64_v2
|
elarch=x86_64_v2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1848,13 +1866,13 @@ verify_os_name() {
|
|||||||
'opencloudos 8|9|23' \
|
'opencloudos 8|9|23' \
|
||||||
'almalinux 8|9|10' \
|
'almalinux 8|9|10' \
|
||||||
'rocky 8|9|10' \
|
'rocky 8|9|10' \
|
||||||
'oracle 8|9' \
|
'oracle 8|9|10' \
|
||||||
'fedora 41|42' \
|
'fedora 41|42' \
|
||||||
'nixos 25.05' \
|
'nixos 25.05' \
|
||||||
'debian 9|10|11|12|13' \
|
'debian 9|10|11|12|13' \
|
||||||
'opensuse 15.6|16.0|tumbleweed' \
|
'opensuse 15.6|16.0|tumbleweed' \
|
||||||
'alpine 3.19|3.20|3.21|3.22' \
|
'alpine 3.19|3.20|3.21|3.22' \
|
||||||
'openeuler 20.03|22.03|24.03|25.03' \
|
'openeuler 20.03|22.03|24.03|25.09' \
|
||||||
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.04' \
|
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.04' \
|
||||||
'redhat' \
|
'redhat' \
|
||||||
'kali' \
|
'kali' \
|
||||||
|
141
trans.sh
141
trans.sh
@@ -442,7 +442,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
umount_all() {
|
umount_all() {
|
||||||
dirs="/mnt /os /iso /wim /installer /nbd /nbd-boot /nbd-efi /root /nix"
|
dirs="/mnt /os /iso /wim /installer /nbd /nbd-boot /nbd-efi /nbd-test /root /nix"
|
||||||
regex=$(echo "$dirs" | sed 's, ,|,g')
|
regex=$(echo "$dirs" | sed 's, ,|,g')
|
||||||
if mounts=$(mount | grep -Ew "on $regex" | awk '{print $3}' | tac); then
|
if mounts=$(mount | grep -Ew "on $regex" | awk '{print $3}' | tac); then
|
||||||
for mount in $mounts; do
|
for mount in $mounts; do
|
||||||
@@ -4447,12 +4447,36 @@ install_qcow_by_copy() {
|
|||||||
# 安装引导
|
# 安装引导
|
||||||
if is_efi; then
|
if is_efi; then
|
||||||
# 只有centos 和 oracle x86_64 镜像没有efi,其他系统镜像已经从efi分区复制了文件
|
# 只有centos 和 oracle x86_64 镜像没有efi,其他系统镜像已经从efi分区复制了文件
|
||||||
if [ -z "$efi_part" ]; then
|
# openeuler 自带 grub2-efi-ia32,此时安装 grub2-efi 提示已经安装了 grub2-efi-ia32,不会继续安装 grub2-efi-x64
|
||||||
remove_grub_conflict_files
|
|
||||||
# openeuler 自带 grub2-efi-ia32,此时安装 grub2-efi 提示已经安装了 grub2-efi-ia32,不会继续安装 grub2-efi-x64
|
# 假设极端情况,qcow2 制作时,安装 grub2-efi-x64 时没有挂载 efi 分区,那么 efi 文件会在系统分区下
|
||||||
[ "$(uname -m)" = x86_64 ] && arch=x64 || arch=aa64
|
# 但我们复制系统分区时挂载了 /boot/efi,因此 efi 文件会正确地复制到 efi 分区
|
||||||
|
# 因此无需判断 qcow2 的 efi 是否是独立分区
|
||||||
|
|
||||||
|
# rhel 镜像没有源,直接 yum install 安装可能会报错
|
||||||
|
# 因此如果已经安装了要用的包就不再运行 yum install
|
||||||
|
need_install=false
|
||||||
|
need_remove_grub_conflict_files=false
|
||||||
|
|
||||||
|
[ "$(uname -m)" = x86_64 ] && arch=x64 || arch=aa64
|
||||||
|
if ! chroot $os_dir rpm -qi grub2-efi-$arch; then
|
||||||
|
need_install=true
|
||||||
|
need_remove_grub_conflict_files=true
|
||||||
|
elif ! chroot $os_dir rpm -qi shim-$arch || ! chroot $os_dir rpm -qi efibootmgr; then
|
||||||
|
need_install=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $need_install; then
|
||||||
|
if $need_remove_grub_conflict_files; then
|
||||||
|
remove_grub_conflict_files
|
||||||
|
fi
|
||||||
chroot_dnf install efibootmgr grub2-efi-$arch shim-$arch
|
chroot_dnf install efibootmgr grub2-efi-$arch shim-$arch
|
||||||
fi
|
fi
|
||||||
|
# openeuler arm 25.09 云镜像里面的 grubaa64.efi 是用于 mbr 分区表,$root 是 hd0,msdos1
|
||||||
|
# 因此要重新下载 $root 是 hd0,gpt1 的 grubaa64.efi
|
||||||
|
if $need_reinstall_grub_efi; then
|
||||||
|
chroot_dnf reinstall grub2-efi-$arch
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# bios
|
# bios
|
||||||
remove_grub_conflict_files
|
remove_grub_conflict_files
|
||||||
@@ -4799,25 +4823,76 @@ EOF
|
|||||||
lvchange -ay "$vg"
|
lvchange -ay "$vg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO: 系统分区应该是最后一个分区
|
mount_nouuid() {
|
||||||
# 选择最大分区
|
part_fstype=
|
||||||
os_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE | grep -E 'ext4|xfs' | tail -1 | awk '{print $1}')
|
for arg in "$@"; do
|
||||||
efi_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,PARTTYPE | grep -i "$EFI_UUID" | awk '{print $1}')
|
case "$arg" in
|
||||||
# 排除前两个,再选择最大分区
|
/dev/*)
|
||||||
# almalinux9 boot 分区的类型不是规定的 uuid
|
part_fstype=$(lsblk -no FSTYPE "$arg")
|
||||||
# openeuler boot 分区是 fat 格式
|
break
|
||||||
boot_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE | grep -E 'ext4|xfs|fat' | awk '{print $1}' |
|
;;
|
||||||
grep -vx "$os_part" | grep -vx "$efi_part" | tail -1 | awk '{print $1}')
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if $is_lvm_image; then
|
case "$part_fstype" in
|
||||||
os_part="mapper/$os_part"
|
xfs) mount -o nouuid "$@" ;;
|
||||||
|
*) mount "$@" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# 可以直接选择最后一个分区为系统分区?
|
||||||
|
# almalinux9 boot 分区的类型不是规定的 uuid
|
||||||
|
# openeuler boot 分区是 vfat 格式
|
||||||
|
# openeuler arm 25.09 是 mbr 分区表, efi boot 是同一个分区,vfat 格式
|
||||||
|
|
||||||
|
info "qcow2 Partitions check"
|
||||||
|
|
||||||
|
# 检测分区表类型
|
||||||
|
partition_table_format=$(get_partition_table_format /dev/nbd0)
|
||||||
|
need_reinstall_grub_efi=false
|
||||||
|
if is_efi && [ "$partition_table_format" = "msdos" ]; then
|
||||||
|
need_reinstall_grub_efi=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 通过检测文件判断是什么分区
|
||||||
|
os_part='' boot_part='' efi_part=''
|
||||||
|
mkdir -p /nbd-test
|
||||||
|
for part in $(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE |
|
||||||
|
grep -E ' (ext4|xfs|fat|vfat)$' | awk '{print $1}' | tac); do
|
||||||
|
mapper_part=$part
|
||||||
|
if $is_lvm_image && [ -e /dev/mapper/$part ]; then
|
||||||
|
mapper_part=mapper/$part
|
||||||
|
fi
|
||||||
|
|
||||||
|
if mount_nouuid -o ro /dev/$mapper_part /nbd-test; then
|
||||||
|
if { ls /nbd-test/etc/os-release || ls /nbd-test/*/etc/os-release; } 2>/dev/null; then
|
||||||
|
os_part=$mapper_part
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC2010
|
||||||
|
# 当 boot 作为独立分区时,vmlinuz 等文件在根目录
|
||||||
|
# 当 boot 不是独立分区时,vmlinuz 等文件在 /boot 目录
|
||||||
|
if ls /nbd-test/ /nbd-test/boot/ 2>/dev/null | grep -Ei '^(vmlinuz|initrd|initramfs)'; then
|
||||||
|
boot_part=$mapper_part
|
||||||
|
fi
|
||||||
|
# mbr + efi 引导 ,分区表没有 esp guid
|
||||||
|
# 因此需要用 efi 文件判断是否 efi 分区
|
||||||
|
# efi 文件可能在 efi 目录的子目录,子目录层数不定
|
||||||
|
if find /nbd-test/ -type f -ipath '/nbd-test/EFI/*.efi' 2>/dev/null | grep .; then
|
||||||
|
efi_part=$mapper_part
|
||||||
|
fi
|
||||||
|
umount /nbd-test
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
info "qcow2 Partitions"
|
info "qcow2 Partitions"
|
||||||
lsblk -f /dev/nbd0 -o +PARTTYPE
|
lsblk -f /dev/nbd0 -o +PARTTYPE
|
||||||
|
# 显示 OS/EFI/Boot 文件在哪个分区
|
||||||
|
echo "---"
|
||||||
|
echo "Table: $partition_table_format"
|
||||||
echo "Part OS: $os_part"
|
echo "Part OS: $os_part"
|
||||||
echo "Part EFI: $efi_part"
|
echo "Part EFI: $efi_part"
|
||||||
echo "Part Boot: $boot_part"
|
echo "Part Boot: $boot_part"
|
||||||
|
echo "---"
|
||||||
|
|
||||||
# 分区寻找方式
|
# 分区寻找方式
|
||||||
# 系统/分区 cmdline:root fstab:efi
|
# 系统/分区 cmdline:root fstab:efi
|
||||||
@@ -4825,25 +4900,16 @@ EOF
|
|||||||
# ubuntu PARTUUID LABEL=UEFI
|
# ubuntu PARTUUID LABEL=UEFI
|
||||||
# 其他el/ol UUID UUID
|
# 其他el/ol UUID UUID
|
||||||
|
|
||||||
# read -r os_part_uuid os_part_label < <(lsblk /dev/$os_part -no UUID,LABEL)
|
IFS=, read -r os_part_uuid os_part_label os_part_fstype \
|
||||||
os_part_uuid=$(lsblk /dev/$os_part -no UUID)
|
< <(lsblk /dev/$os_part -rno UUID,LABEL,FSTYPE | tr ' ' ,)
|
||||||
os_part_label=$(lsblk /dev/$os_part -no LABEL)
|
|
||||||
os_part_fstype=$(lsblk /dev/$os_part -no FSTYPE)
|
|
||||||
|
|
||||||
if [ -n "$efi_part" ]; then
|
if [ -n "$efi_part" ]; then
|
||||||
efi_part_uuid=$(lsblk /dev/$efi_part -no UUID)
|
IFS=, read -r efi_part_uuid efi_part_label \
|
||||||
efi_part_label=$(lsblk /dev/$efi_part -no LABEL)
|
< <(lsblk /dev/$efi_part -rno UUID,LABEL | tr ' ' ,)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /nbd /nbd-boot /nbd-efi
|
mkdir -p /nbd /nbd-boot /nbd-efi
|
||||||
|
|
||||||
mount_nouuid() {
|
|
||||||
case "$os_part_fstype" in
|
|
||||||
ext4) mount "$@" ;;
|
|
||||||
xfs) mount -o nouuid "$@" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# 使用目标系统的格式化程序
|
# 使用目标系统的格式化程序
|
||||||
# centos8 如果用alpine格式化xfs,grub2-mkconfig和grub2里面都无法识别xfs分区
|
# centos8 如果用alpine格式化xfs,grub2-mkconfig和grub2里面都无法识别xfs分区
|
||||||
mount_nouuid /dev/$os_part /nbd/
|
mount_nouuid /dev/$os_part /nbd/
|
||||||
@@ -4879,16 +4945,17 @@ EOF
|
|||||||
cp -a /nbd/* /os/
|
cp -a /nbd/* /os/
|
||||||
umount /nbd/
|
umount /nbd/
|
||||||
|
|
||||||
# 复制boot分区,如果有
|
# 复制独立的boot分区,如果有
|
||||||
if [ -n "$boot_part" ]; then
|
if [ -n "$boot_part" ] && ! [ "$boot_part" = "$os_part" ]; then
|
||||||
echo Copying boot partition...
|
echo Copying boot partition...
|
||||||
mount_nouuid -o ro /dev/$boot_part /nbd-boot/
|
mount_nouuid -o ro /dev/$boot_part /nbd-boot/
|
||||||
cp -a /nbd-boot/* /os/boot/
|
cp -a /nbd-boot/* /os/boot/
|
||||||
umount /nbd-boot/
|
umount /nbd-boot/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 复制efi分区,如果有
|
# 复制独立的efi分区,如果有
|
||||||
if [ -n "$efi_part" ]; then
|
# 如果 efi 和 boot 是同一个分区,则复制 boot 分区时已经复制了 efi 分区的文件
|
||||||
|
if [ -n "$efi_part" ] && ! [ "$efi_part" = "$os_part" ] && ! [ "$efi_part" = "$boot_part" ]; then
|
||||||
echo Copying efi partition...
|
echo Copying efi partition...
|
||||||
mount -o ro /dev/$efi_part /nbd-efi/
|
mount -o ro /dev/$efi_part /nbd-efi/
|
||||||
cp -a /nbd-efi/* /os/boot/efi/
|
cp -a /nbd-efi/* /os/boot/efi/
|
||||||
@@ -4912,11 +4979,11 @@ EOF
|
|||||||
umount /os/
|
umount /os/
|
||||||
umount /installer/
|
umount /installer/
|
||||||
|
|
||||||
# 如果镜像有efi分区,复制其uuid
|
# 如果镜像有独立的efi分区(包括efi+boot在同一个分区),复制其uuid
|
||||||
# 如果有相同uuid的fat分区,则无法挂载
|
# 如果有相同uuid的fat分区,则无法挂载
|
||||||
# 所以要先复制efi分区,断开nbd再复制uuid
|
# 所以要先复制efi分区,断开nbd再复制uuid
|
||||||
# 复制uuid前要取消挂载硬盘 efi 分区
|
# 复制uuid前要取消挂载硬盘 efi 分区
|
||||||
if is_efi && [ -n "$efi_part_uuid" ]; then
|
if is_efi && [ -n "$efi_part_uuid" ] && ! [ "$efi_part" = "$os_part" ]; then
|
||||||
info "Copy efi partition uuid"
|
info "Copy efi partition uuid"
|
||||||
apk add mtools
|
apk add mtools
|
||||||
mlabel -N "$(echo $efi_part_uuid | sed 's/-//')" -i /dev/$xda*1 ::$efi_part_label
|
mlabel -N "$(echo $efi_part_uuid | sed 's/-//')" -i /dev/$xda*1 ::$efi_part_label
|
||||||
@@ -5867,7 +5934,7 @@ install_windows() {
|
|||||||
'2012' | '2012 r2') echo 772074/Wired_driver_28.0_${arch_intel}.zip ;;
|
'2012' | '2012 r2') echo 772074/Wired_driver_28.0_${arch_intel}.zip ;;
|
||||||
*) case "${arch_intel}" in
|
*) case "${arch_intel}" in
|
||||||
32) echo 849483/Wired_driver_30.0.1_${arch_intel}.zip ;;
|
32) echo 849483/Wired_driver_30.0.1_${arch_intel}.zip ;;
|
||||||
x64) echo 861427/Wired_driver_30.3_${arch_intel}.zip ;;
|
x64) echo 864508/Wired_driver_30.4_${arch_intel}.zip ;;
|
||||||
esac ;;
|
esac ;;
|
||||||
esac
|
esac
|
||||||
)
|
)
|
||||||
@@ -6475,7 +6542,7 @@ EOF
|
|||||||
done
|
done
|
||||||
|
|
||||||
if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then
|
if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then
|
||||||
url=https://downloadmirror.intel.com/849939/SetupRST.exe # RST v20
|
url=https://downloadmirror.intel.com/865363/SetupRST.exe # RST v20
|
||||||
elif [ "$build_ver" -ge 15063 ]; then
|
elif [ "$build_ver" -ge 15063 ]; then
|
||||||
url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19
|
url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user