diff --git a/README.en.md b/README.en.md
index 346519d..85e40b4 100644
--- a/README.en.md
+++ b/README.en.md
@@ -1,71 +1,115 @@
+
+
# reinstall
-[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc679a17751448628fe6d8ac35e26eed)](https://app.codacy.com/gh/bin456789/reinstall/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
-[![CodeFactor](https://www.codefactor.io/repository/github/bin456789/reinstall/badge)](https://www.codefactor.io/repository/github/bin456789/reinstall)
-[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat)](https://github.com/XAMPPRocky/tokei_rs)
+[![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy)](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
+[![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor)](https://www.codefactor.io/repository/github/bin456789/reinstall)
+[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat&label=Lines%20of%20Code)](https://github.com/XAMPPRocky/tokei_rs)
-One-click reinstallation script
-
-[中文](README.md) | English
+Reinstall server with one-click [中文](README.md)
## Highlights
-- Support arbitrary conversion between the following systems (including Windows to Linux).
-- Compatible low-spec servers and automatically select the appropriate official slimmed-down kernel.
-- Supports installing Windows using the official ISO.
-- Automatically detect dynamic/static IPv4/IPv6, eliminating the need to fill in IP/mask/gateway (even for DD/ISO installation of Windows).
-- Supports BIOS, EFI, ARM. The original system partition supports LVM, Btrfs.
-- Progress of DD and cloud image installation can be viewed through SSH, HTTP port 80, serial console, and vendor backend VNC.
-- The script does not include third-party homemade packages; all resources are obtained in real-time from the source site.
+- Support installation of 12 common Linux distributions.
+- Support for installing Windows using the official original ISO. The script can automatically search for the ISO and drivers.
+- Support reinstallation in any direction, meaning `Linux to Linux`, `Linux to Win`, `Win to Win`, `Win to Linux`.
+- Specifically tailored for low-spec machines, addressing insufficient memory that prevents network installation.
+- Automatically detect dynamic and static IPv4 / IPv6, eliminating the need to fill in IP / subnet mask / gateway.
+- Support ARM, BIOS, EFI boot, with original system supporting LVM, BTRFS.
+- No third-party custom packages included, all resources obtained in real-time from source sites.
- Includes many comments.
## System Requirements
-| Target System | Memory | Disk |
-| -------------------------------------------------------- | --------- | ---------------------- |
-| Alpine | 256 MB | 1 GB |
-| Debian / Kali | 256 MB | 1~1.5 GB ^ |
-| Ubuntu | 512 MB \* | 2 GB |
-| CentOS / Alma / Rocky / Oracle | 512 MB \* | 5 GB |
-| Fedora | 512 MB \* | 5 GB |
-| openSUSE | 512 MB \* | 5 GB |
-| Arch | 512 MB | 5 GB |
-| Gentoo | 512 MB | 5 GB |
-| DD | 512 MB | Depending on the image |
-| Windows 8.1 (Server 2012 R2) or below (ISO installation) | 512 MB | 20~25 GB |
-| Windows 10 (Server 2016) or above (ISO installation) | 1G | 20~25 GB |
+| Target System | Version | Memory | Disk |
+| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ---------------------- |
+| Alpine | 3.17, 3.18, 3.19, 3.20 | 256 MB | 1 GB |
+| Debian | 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ |
+| Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
+| Ubuntu | 20.04, 22.04, 24.04 | 512 MB \* | 2 GB |
+| CentOS | 7, 8, 9 | 512 MB \* | 5 GB |
+| Oracle | 7, 8, 9 | 512 MB \* | 5 GB |
+| Alma | 8, 9 | 512 MB \* | 5 GB |
+| Rocky | 8, 9 | 512 MB \* | 5 GB |
+| Fedora | 39, 40 | 512 MB \* | 5 GB |
+| openSUSE | 15.5, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
+| Arch | Rolling | 512 MB | 5 GB |
+| Gentoo | Rolling | 512 MB | 5 GB |
+| Windows (DD) | Any | 512 MB | Depending on the image |
+| Windows (ISO) | Vista, 7, 8.x (Server 2008 ~ 2012 R2) | 512 MB | 25 GB |
+| Windows (ISO) | 10, 11 (Server 2016 ~ 2022) | 1 GB | 25 GB |
-(\*) Indicates installation using cloud images
+(\*) Indicates installation using cloud images, not traditional network installation.
(^) indicates requiring either 256 MB memory + 1.5 GB disk, or 512 MB memory + 1 GB disk
-## Download (Current system is Linux)
+> [!WARNING]
+> ❌ This script does not support OpenVZ or LXC virtual machines.
+>
+> Please use instead.
-For users outside China:
+## System Accounts
+
+| System | Username | Password |
+| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------- |
+| Linux | root | 123@@@ |
+| Windows (ISO) | administrator | 123@@@ |
+| Windows (DD) | Image username | Image password |
+
+> [!TIP]
+> If remote login to Windows fails, try using the username `.\administrator`.
+
+## Download (Current system is Linux)
+
+For server outside China:
```bash
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
```
-For users in China:
+For server inside China:
```bash
curl -O https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
```
-## Download (Current system is Windows)
+## Download (Current system is Windows)
-[Unable to download?](#if-the-script-cannot-be-downloaded-under-windows)
+> [!IMPORTANT]
+> Before proceeding, please disable the 'Real-time protection' feature in `Windows Defender`. This feature may prevent `certutil` from downloading any files.
-Before proceeding, please disable the 'Real-time protection' feature in `Windows Defender`. This feature may prevent `certutil` from downloading any files.
+
-For users outside China:
+😢Still unable to download?
+
+### Try the following methods
+
+1. For Windows 7, install this patch to enable TLS 1.2.
+
+
+
+2. Update SSL root certificates.
+
+ ```batch
+ certutil -generateSSTFromWU root.sst
+ certutil -addstore Root root.sst
+ ```
+
+3. Download manually by copying these two files through `Remote Desktop Connection`.
+
+
+
+
+
+
+
+For server outside China:
```batch
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
```
-For users in China:
+For server inside China:
```batch
certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
@@ -73,26 +117,34 @@ certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubuserco
## Usage
-All features can be used on both Linux and Windows.
+> [!TIP]
+> All features can be used on both Linux and Windows.
+>
+> on Linux, execute `bash reinstall.sh`
+>
+> on Windows, execute `reinstall.bat`
-- on Linux, execute `bash reinstall.sh`
-- on Windows, execute `reinstall.bat`
-
-### Feature 1: Install Linux
+### Feature 1: Install Linux
- If no version number is entered, the latest version will be installed.
-- When installing on a virtual machine, it will automatically select a slimmed-down kernel.
+- Does not include a boot partition (except for Fedora), nor a swap partition, maximizing disk space utilization.
+- When installing on a virtual machine, it will automatically select a official limmed-down kernel.
+
+> [!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).
```bash
bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
oracle 7|8|9
alma 8|9
rocky 8|9
- fedora 38|39|40
+ fedora 39|40
debian 10|11|12
opensuse 15.5|tumbleweed
ubuntu 20.04|22.04|24.04
- alpine 3.16|3.17|3.18|3.19
+ alpine 3.17|3.18|3.19|3.20
kali
arch
gentoo
@@ -103,11 +155,14 @@ bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
- Supports gzip, xz formats.
- For machines with static IP, DD Windows, and the script will automatically configure the IP.
+> [!TIP]
+> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
+
```bash
bash reinstall.sh dd --img https://example.com/xxx.xz
```
-### Feature 3: Reboot to Alpine Rescue System (Live OS)
+### Feature 3: Reboot to Alpine Rescue System (Live OS)
- Can be connected via SSH to perform manual DD, modify partitions, manually install Arch / Gentoo, etc.
- If the disk content is not modified, rebooting again will return to the original system.
@@ -116,7 +171,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz
bash reinstall.sh alpine --hold=1
```
-### Feature 4: Reboot to netboot.xyz
+### Feature 4: Reboot to netboot.xyz
- Can 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 the disk content is not modified, rebooting again will return to the original system.
@@ -127,10 +182,17 @@ bash reinstall.sh netboot.xyz
![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif)
-### Feature 5: Install Windows ISO
+### Feature 5: Install Windows ISO
-- Pay attention to the quotation marks around the parameters
-- Supports automatically searching for some ISO links. Need to set the language using `--lang`, default is `en-us`.
+- Can automatically searching for most iso links. Need to set the language using `--lang`, default is `en-us`.
+- Machines with static IP addresses will have their IPs automatically configured after installation.
+- Can bypass Windows 11 installation restrictions.
+
+> [!TIP]
+> The script uses as the ISO source. All ISOs provided are official originals.
+
+> [!IMPORTANT]
+> Note that parameters should be enclosed in quotation marks.
```bash
bash reinstall.sh windows \
@@ -146,9 +208,28 @@ bash reinstall.sh windows \
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
```
+
+
+The following website provides iso links.
+
+- Massgrave
+ - (Recommended, iso sourced from official channels, updated monthly, includes the latest patches)
+- Microsoft
+ -
+ - (Need to open it with a mobile User-Agent)
+ -
+ -
+ -
+ -
+ -
+ -
+ -
+
+
+
![Installing Windows](https://github.com/bin456789/reinstall/assets/7548515/07c1aea2-1ce3-4967-904f-aaf9d6eec3f7)
-Parameters Description:
+#### Parameters Description
`--image-name` Specify the image to install, case-insensitive, Commonly used images include:
@@ -163,78 +244,36 @@ Use `Dism++` File menu > Open Image File, select the iso to be installed to get
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
-1. Supported systems:
- - Windows Vista to 11
- - Windows Server 2008 to 2022, including the following variants
- - Windows Server Essentials
- - Windows Server Annual Channel
- - Hyper-V Server
- - Azure Stack HCI
-2. The script will install the following drivers as needed:
- - KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/))
- - XEN ([XEN](https://xenproject.org/windows-pv-drivers/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html))
- - AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html))
- - GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Graphics](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))
-3. Vista (Server 2008) and 32-bit systems may lack drivers.
-4. For EFI machines without CSM enabled, Windows 7 (Server 2008 R2) cannot be installed.
-5. If the machine has a static IP, the IP will be automatically set after installation.
-6. Can bypass Windows 11 hardware restrictions.
-7. Supports Windows 11 on ARM, exclusively for Hyper-V (Azure), not compatible with KVM (Oracle Cloud).
-8. The process `wsappx` will occupy CPU for a long time after installing the image `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`.
+#### Supported systems
- This is an issue with the image, and the solution is to install the `VCLibs` library.
+- Windows (Vista ~ 11)
+- Windows Server (2008 ~ 2022)
+ - Windows Server Essentials
+ - Windows Server (Semi) Annual Channel
+ - Hyper-V Server
+ - Azure Stack HCI
-
+#### The script will install the following drivers as needed
-9. The following website provides iso links.
+- KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/))
+- XEN ([XEN](https://xenproject.org/windows-pv-drivers/), [Citrix](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade), [AWS](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html))
+- AWS ([ENA Network Adapter](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html), [NVMe Storage Controller](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html))
+- GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Graphics](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))
- (Recommended, iso sourced from official channels, updated monthly, includes the latest patches)
+> [!WARNING]
+> 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.
- (Need to open it with a mobile User-Agent)
+> [!WARNING]
+> Supports installation of Windows 11 on ARM machines, limited to Hyper-V (Azure) only, not supported on KVM (Oracle Cloud).
-
-
-## Virtualization Requirements
-
-Not supported on OpenVZ, LXC virtual machines.
-
-Please use .
-
-## Default Passwords
-
-| System | Username | Password |
-| ------------- | -------------- | -------------- |
-| Linux | root | 123@@@ |
-| Windows (iso) | administrator | 123@@@ |
-| Windows (dd) | Image username | Image password |
-
-If encountering a password error during remote login to Windows, try using the username .\administrator.
-
-## If the script cannot be downloaded under Windows
-
-You can try the following methods:
-
-1. Disable Windows Defender Real-time Protection.
-
-2. For Windows 7, install this patch to enable TLS 1.2.
-
-
-
-3. Update SSL root certificates.
-
- ```batch
- certutil -generateSSTFromWU root.sst
- certutil -addstore Root root.sst
- ```
-
-4. Download manually by copying these two files through `Remote Desktop Connection`.
-
-
-
-
+> [!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 .
## Thanks
diff --git a/README.md b/README.md
index 1499d11..7a85a2a 100644
--- a/README.md
+++ b/README.md
@@ -1,71 +1,115 @@
+
+
# reinstall
-[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc679a17751448628fe6d8ac35e26eed)](https://app.codacy.com/gh/bin456789/reinstall/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
-[![CodeFactor](https://www.codefactor.io/repository/github/bin456789/reinstall/badge)](https://www.codefactor.io/repository/github/bin456789/reinstall)
-[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat)](https://github.com/XAMPPRocky/tokei_rs)
+[![Codacy](https://img.shields.io/codacy/grade/dc679a17751448628fe6d8ac35e26eed?logo=Codacy&label=Codacy)](https://app.codacy.com/gh/bin456789/reinstall/dashboard)
+[![CodeFactor](https://img.shields.io/codefactor/grade/github/bin456789/reinstall?logo=CodeFactor&logoColor=white&label=CodeFactor)](https://www.codefactor.io/repository/github/bin456789/reinstall)
+[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat&label=Lines%20of%20Code)](https://github.com/XAMPPRocky/tokei_rs)
-一键重装脚本
-
-中文 | [English](README.en.md)
+一键重装脚本 [English](README.en.md)
## 亮点
-- 支持以下系统任意转换(包括 Windows 转 Linux)
-- 适配低配小鸡,并自动选择合适的官方精简内核
-- 支持用官方 iso 安装 Windows
-- 自动判断动静态 IPv4 / IPv6,无需填写 IP / 掩码 / 网关(即使是 DD / ISO 安装 Windows)
-- 支持 BIOS、EFI、ARM,原系统分区支持 lvm、btrfs
-- 可通过 SSH、HTTP 80 端口、串行控制台、商家后台 VNC 查看 DD、云镜像安装进度
+- 支持安装 12 种常见 Linux 发行版
+- 支持用官方原版 iso 安装 Windows,并且脚本会自动查找 iso 和驱动
+- 支持任意方向重装,也就是支持 `Linux to Linux`、`Linux to Win`、`Win to Win`、`Win to Linux`
+- 专门适配低配小鸡,解决内存过少导致无法进行网络安装
+- 自动判断动静态 IPv4 / IPv6,无需填写 IP / 掩码 / 网关
+- 支持 ARM,支持 BIOS、EFI 引导,原系统支持 LVM、BTRFS
- 不含第三方自制包,所有资源均实时从源站点获得
- 有很多注释
## 配置要求
-| 目标系统 | 内存 | 硬盘 |
-| ---------------------------------------------- | --------- | ---------- |
-| Alpine | 256 MB | 1 GB |
-| Debian / Kali | 256 MB | 1~1.5 GB ^ |
-| Ubuntu | 512 MB \* | 2 GB |
-| CentOS / Alma / Rocky / Oracle | 512 MB \* | 5 GB |
-| Fedora | 512 MB \* | 5 GB |
-| openSUSE | 512 MB \* | 5 GB |
-| Arch | 512 MB | 5 GB |
-| Gentoo | 512 MB | 5 GB |
-| DD | 512 MB | 取决于镜像 |
-| Windows 8.1 (Server 2012 R2) 或以下 (ISO 安装) | 512 MB | 20~25 GB |
-| Windows 10 (Server 2016) 或以上 (ISO 安装) | 1024 MB | 20~25 GB |
+| 目标系统 | 版本 | 内存 | 硬盘 |
+| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | --------- | ------------ |
+| Alpine | 3.17, 3.18, 3.19, 3.20 | 256 MB | 1 GB |
+| Debian | 10, 11, 12 | 256 MB | 1 ~ 1.5 GB ^ |
+| Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
+| Ubuntu | 20.04, 22.04, 24.04 | 512 MB \* | 2 GB |
+| CentOS | 7, 8, 9 | 512 MB \* | 5 GB |
+| Oracle | 7, 8, 9 | 512 MB \* | 5 GB |
+| Alma | 8, 9 | 512 MB \* | 5 GB |
+| Rocky | 8, 9 | 512 MB \* | 5 GB |
+| Fedora | 39, 40 | 512 MB \* | 5 GB |
+| openSUSE | 15.5, Tumbleweed (滚动) | 512 MB \* | 5 GB |
+| Arch | 滚动 | 512 MB | 5 GB |
+| Gentoo | 滚动 | 512 MB | 5 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 ~ 2022) | 1 GB | 25 GB |
-(\*) 表示使用云镜像安装
+(\*) 表示使用云镜像安装,非传统网络安装
(^) 需要 256 MB 内存 + 1.5 GB 硬盘,或 512 MB 内存 + 1 GB 硬盘
-## 下载(当前系统是 Linux)
+> [!WARNING]
+> ❌ 本脚本不支持 OpenVZ、LXC 虚拟机
+>
+> 请改用
-国外:
+## 系统账号
+
+| 系统 | 用户名 | 密码 |
+| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -------- |
+| Linux | root | 123@@@ |
+| Windows (ISO) | administrator | 123@@@ |
+| Windows (DD) | 镜像用户名 | 镜像密码 |
+
+> [!TIP]
+> 如果远程登录 Windows 失败,尝试使用用户名 `.\administrator`
+
+## 下载(当前系统是 Linux)
+
+国外服务器:
```bash
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
```
-国内:
+国内服务器:
```bash
curl -O https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
```
-## 下载(当前系统是 Windows)
+## 下载(当前系统是 Windows)
-[无法下载?](#如果-windows-下无法下载脚本)
+> [!IMPORTANT]
+> 请先关闭 `Windows Defender` 的 `实时保护` 功能。该功能会阻止 `certutil` 下载任何文件。
-请先关闭 `Windows Defender` 的 `实时保护` 功能。该功能会阻止 `certutil` 下载任何文件
+
-国外:
+😢还是无法下载?
+
+### 可尝试以下几种方法
+
+1. Windows 7 安装此补丁启用 TLS 1.2
+
+
+
+2. 更新 SSL 根证书
+
+ ```batch
+ certutil -generateSSTFromWU root.sst
+ certutil -addstore Root root.sst
+ ```
+
+3. 手动下载,通过 `远程桌面` 复制这两个文件
+
+
+
+
+
+
+
+国外服务器:
```batch
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
```
-国内:
+国内服务器:
```batch
certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
@@ -73,26 +117,35 @@ certutil -urlcache -f -split https://mirror.ghproxy.com/https://raw.githubuserco
## 使用
-所有功能均可在 Linux / Windows 下使用
+> [!TIP]
+>
+> 所有功能均可在 Linux / Windows 下使用。
+>
+> Linux 下运行 `bash reinstall.sh`
+>
+> Windows 下运行 `reinstall.bat`
-- Linux 下运行 `bash reinstall.sh`
-- Windows 下运行 `reinstall.bat`
-
-### 功能 1: 安装 Linux
+### 功能 1: 安装 Linux
- 不输入版本号,则安装最新版
-- 在虚拟机上,会自动安装精简内核
+- 不含 boot 分区(Fedora 例外),不含 swap 分区,最大化利用磁盘空间
+- 在虚拟机上,会自动安装官方精简内核
+
+> [!TIP]
+> 安装 Debian / Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。
+>
+> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
```bash
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
oracle 7|8|9
alma 8|9
rocky 8|9
- fedora 38|39|40
+ fedora 39|40
debian 10|11|12
opensuse 15.5|tumbleweed
ubuntu 20.04|22.04|24.04
- alpine 3.16|3.17|3.18|3.19
+ alpine 3.17|3.18|3.19|3.20
kali
arch
gentoo
@@ -103,11 +156,14 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
- 支持 gzip、xz 格式
- 静态 IP 的机器 DD Windows,会自动配置好 IP
+> [!TIP]
+> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
+
```bash
bash reinstall.sh dd --img https://example.com/xxx.xz
```
-### 功能 3: 重启到 Alpine 救援系统 (Live OS)
+### 功能 3: 重启到 Alpine 救援系统 (Live OS)
- 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch / Gentoo 等操作
- 如果没有修改硬盘内容,再次重启将回到原系统
@@ -116,7 +172,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz
bash reinstall.sh alpine --hold=1
```
-### 功能 4: 重启到 netboot.xyz
+### 功能 4: 重启到 netboot.xyz
- 可使用商家后台 VNC 安装 [更多系统](https://github.com/netbootxyz/netboot.xyz?tab=readme-ov-file#what-operating-systems-are-currently-available-on-netbootxyz)
- 如果没有修改硬盘内容,再次重启将回到原系统
@@ -127,10 +183,17 @@ bash reinstall.sh netboot.xyz
![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif)
-### 功能 5: 安装 Windows ISO
+### 功能 5: 安装 Windows ISO
-- 注意参数两边的引号
-- 支持自动查找部分 iso 链接,需设置语言 `--lang`,默认 `en-us`
+- 支持自动查找大部分 iso 链接,需指定语言 `--lang`,默认 `en-us`
+- 静态 IP 的机器,安装后会自动配置好 IP
+- 能够绕过 Windows 11 安装限制
+
+> [!TIP]
+> 脚本以 作为 iso 镜像查找源。所有 iso 都是官方原版。
+
+> [!IMPORTANT]
+> 注意参数两边有引号。
```bash
bash reinstall.sh windows \
@@ -146,9 +209,28 @@ bash reinstall.sh windows \
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso'
```
+
+
+以下网站可找到 iso 链接
+
+- Massgrave
+ - (推荐,iso 来自官方,每月更新,包含最新补丁)
+- 微软
+ -
+ - (需用手机 User-Agent 打开)
+ -
+ -
+ -
+ -
+ -
+ -
+ -
+
+
+
![Installing Windows](https://github.com/bin456789/reinstall/assets/7548515/07c1aea2-1ce3-4967-904f-aaf9d6eec3f7)
-参数说明:
+#### 参数说明
`--image-name` 指定要安装的映像,不区分大小写,常用映像有:
@@ -163,78 +245,36 @@ Windows Server 2022 SERVERDATACENTER
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
-1. 支持的系统:
- - Windows Vista 到 11
- - Windows Server 2008 到 2022,包括以下衍生版
- - Windows Server Essentials
- - Windows Server Annual Channel
- - Hyper-V Server
- - Azure Stack HCI
-2. 脚本会按需安装以下驱动:
- - KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/))
- - XEN ([XEN](https://xenproject.org/windows-pv-drivers/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html))
- - AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.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))
-3. Vista (Server 2008) 和 32 位系统可能会缺少驱动
-4. 未开启 CSM 的 EFI 机器,无法安装 Windows 7 (Server 2008 R2)
-5. 静态 IP 的机器,安装后会自动配置好 IP
-6. 可绕过 Windows 11 硬件限制
-7. 支持 Windows 11 on ARM,仅限 Hyper-V (Azure) ,不支持 KVM (甲骨文云)
-8. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 此镜像安装后 `wsappx` 进程会长期占用 CPU
+#### 支持的系统
- 这是镜像的问题,解决方法是安装 `VCLibs` 库
+- Windows (Vista ~ 11)
+- Windows Server (2008 ~ 2022)
+ - Windows Server Essentials
+ - Windows Server (Semi) Annual Channel
+ - Hyper-V Server
+ - Azure Stack HCI
-
+#### 脚本会按需安装以下驱动
-9. 以下网站可找到 iso 链接
+- KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/))
+- XEN ([XEN](https://xenproject.org/windows-pv-drivers/)、[Citrix](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Upgrading_PV_drivers.html#win2008-citrix-upgrade)、[AWS](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html))
+- AWS ([ENA 网卡](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html)、[NVME 存储控制器](https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.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))
- (推荐,iso 来自官方,每月更新,包含最新补丁)
+> [!WARNING]
+> Vista (Server 2008) 和 32 位系统可能会缺少驱动
-
+> [!WARNING]
+> 未开启 CSM 的 EFI 机器,无法安装 Windows 7 (Server 2008 R2)
- (需用手机 User-Agent 打开)
+> [!WARNING]
+> 支持 ARM 机器安装 Windows 11,仅限于 Hyper-V (Azure) ,不支持 KVM (甲骨文云)
-
-
-## 虚拟化要求
-
-不支持 OpenVZ、LXC 虚拟机
-
-请使用
-
-## 默认密码
-
-| 系统 | 用户名 | 密码 |
-| ------------- | ------------- | -------- |
-| Linux | root | 123@@@ |
-| Windows (iso) | administrator | 123@@@ |
-| Windows (dd) | 镜像用户名 | 镜像密码 |
-
-如果远程登录 Windows 提示密码错误,尝试用户名 `.\administrator`
-
-## 如果 Windows 下无法下载脚本
-
-可尝试以下几种方法
-
-1. 关闭 Windows Defender 实时保护
-
-2. Windows 7 安装此补丁启用 TLS 1.2
-
-
-
-3. 更新 SSL 根证书
-
- ```batch
- certutil -generateSSTFromWU root.sst
- certutil -addstore Root root.sst
- ```
-
-4. 手动下载,通过 `远程桌面` 复制这两个文件
-
-
-
-
+> [!WARNING]
+> Windows 10 LTSC 2021 中文版镜像 `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 的 `wsappx` 进程会长期占用 CPU
+>
+> 解决方法是更新系统补丁,或者手动安装 `VCLibs` 库
## 感谢
diff --git a/cloud-init-fix-onlink.sh b/cloud-init-fix-onlink.sh
index 6621c43..6346dce 100644
--- a/cloud-init-fix-onlink.sh
+++ b/cloud-init-fix-onlink.sh
@@ -190,10 +190,12 @@ fix_wicked_conf() {
}
# debian 10/11/12: netplan + networkd/resolved
+# 23.1.1 修复
fix_netplan_conf
# arch: networkd/resolved
# gentoo: networkd/resolved
+# 24.2 修复
fix_networkd_conf
# opensuse 15.5: ifcfg + netconfig (dns) + wicked
diff --git a/debian.cfg b/debian.cfg
index fceda8e..1c02e73 100644
--- a/debian.cfg
+++ b/debian.cfg
@@ -1,4 +1,5 @@
-# shellcheck disable=SC2148,SC2154
+#_preseed_V1
+# 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
@@ -109,6 +110,8 @@ d-i finish-install/reboot_in_progress note
# B.5.1. 安装过程中运行用户命令
# 注意所有命令都会合并成一行命令
+# 最后的 true; \ 没什么用,只是让 vscode 代码高亮不报错误
+
# 有 /cdrom/simple-cdd 才安装 simple-cdd-profiles
# 不然安装时 control 脚本会报错:
# Loading simple-cdd-profiles failed for unknown reasons
@@ -118,16 +121,19 @@ d-i preseed/early_command string true; \
# debian 11 initrd 没有 xargs awk
# debian 12 initrd 没有 xargs
# efi 分区大小未改变时,不会被格式化,因此需要手动删除旧系统的 efi 文件
+# os-prober 卡太久,因此跳过
+d-i partman/early_command string true; \
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
- swapfile=/target/swapfile; \
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
cp $postinst $postinst.orig; \
+ true >$postinst; \
- mem=$(grep ^MemTotal: /proc/meminfo | { read x y z; echo $y; }); \
+ swapfile=/target/swapfile; \
+ mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$y"; }); \
mem=$((mem / 1024)); \
swap_size=$((512 - mem)); \
- [ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile; $postinst.orig" >$postinst; \
+ [ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
echo "swapoff -a; rm -f $swapfile" >/usr/lib/finish-install.d/95swapoff; \
chmod a+x /usr/lib/finish-install.d/95swapoff; \
@@ -139,7 +145,7 @@ d-i preseed/early_command string true; \
debconf-set grub-installer/bootdev "/dev/$xda"; \
rm -rf /usr/sbin/fdisk /usr/sbin/sfdisk; \
- ttys=$(wget --tries=5 $confhome/ttys.sh -O- | sh -s console=); \
+ ttys=$(wget --tries=5 "$confhome/ttys.sh" -O- | sh -s console=); \
debconf-set debian-installer/add-kernel-opts "$ttys"; \
sh /can_use_cloud_kernel.sh "$xda" || debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
@@ -149,11 +155,9 @@ d-i preseed/early_command string true; \
true >/bin/os-prober
-# os-prober 卡太久,因此跳过
-
# debian 10 没有 /target/etc/ssh/sshd_config.d/ 文件夹
# kali ssh 默认关闭
-d-i preseed/late_command string \
+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
diff --git a/reinstall.bat b/reinstall.bat
index cbf018f..062ab8f 100644
--- a/reinstall.bat
+++ b/reinstall.bat
@@ -48,6 +48,7 @@ if not errorlevel 1 (
)
)
) else (
+ rem 服务器在美国 equinix 机房,不是 cdn
set mirror=http://mirrors.kernel.org
)
diff --git a/reinstall.sh b/reinstall.sh
index 588a184..0e1d807 100644
--- a/reinstall.sh
+++ b/reinstall.sh
@@ -30,11 +30,11 @@ Usage: $reinstall____ centos 7|8|9
oracle 7|8|9
alma 8|9
rocky 8|9
- fedora 38|39|40
+ fedora 39|40
debian 10|11|12
- ubuntu 20.04|22.04|24.04
- alpine 3.16|3.17|3.18|3.19
opensuse 15.5|tumbleweed
+ ubuntu 20.04|22.04|24.04
+ alpine 3.17|3.18|3.19|3.20
kali
arch
gentoo
@@ -472,15 +472,16 @@ is_have_arm_version() {
case "$version" in
10)
case "$edition" in
- pro | 'pro for workstations' | education | 'pro education' | enterprise) return ;;
+ pro | education | enterprise | 'pro education' | 'pro for workstations') return ;;
'iot enterprise') return ;;
- 'iot enterprise ltsc 2021' | 'enterprise ltsc 2021') return ;;
+ 'enterprise ltsc 2021' | 'iot enterprise ltsc 2021') return ;;
esac
;;
11)
case "$edition" in
- pro | 'pro for workstations' | education | 'pro education' | enterprise) return ;;
+ pro | education | enterprise | 'pro education' | 'pro for workstations') return ;;
'iot enterprise') return ;;
+ 'enterprise ltsc 2024' | 'iot enterprise ltsc 2024' | 'iot enterprise ltsc 2024 subscription') return ;;
esac
;;
esac
@@ -567,7 +568,7 @@ get_windows_iso_links() {
10)
case "$edition" in
home | 'home single language') echo consumer ;;
- pro | 'pro for workstations' | education | 'pro education' | enterprise) echo business ;;
+ pro | education | enterprise | 'pro education' | 'pro for workstations') echo business ;;
'iot enterprise') echo 'iot enterprise' ;;
'enterprise 2015 ltsb' | 'enterprise 2016 ltsb' | 'enterprise ltsc 2019') echo "$edition" ;;
'enterprise ltsc 2021')
@@ -583,8 +584,10 @@ get_windows_iso_links() {
11)
case "$edition" in
home | 'home single language') echo consumer ;;
- pro | 'pro for workstations' | education | 'pro education' | enterprise) echo business ;;
+ pro | education | enterprise | 'pro education' | 'pro for workstations') echo business ;;
'iot enterprise') echo 'iot enterprise' ;;
+ 'enterprise ltsc 2024') echo 'enterprise ltsc 2024' ;;
+ 'iot enterprise ltsc 2024' | 'iot enterprise ltsc 2024 subscription') echo 'iot enterprise ltsc 2024' ;;
esac
;;
esac
@@ -595,7 +598,7 @@ get_windows_iso_links() {
case "$version" in
10 | 11)
case "$edition" in
- pro | 'pro for workstations' | education | 'pro education' | enterprise) echo pro ;;
+ pro | education | enterprise | 'pro education' | 'pro for workstations') echo pro ;;
esac
;;
esac
@@ -640,7 +643,7 @@ get_windows_iso_links() {
error_and_exit "Not support find this iso. Check --image-name or set --iso manually."
fi
- curl -L "$page_url" | grep -ioP 'https://.*?.iso' | awk -F/ '{print $NF}' >$tmp/win.list
+ curl -L "$page_url" | grep -ioP 'https://.*?.iso' >$tmp/win.list
# 如果不是 ltsc ,应该先去除 ltsc 链接,否则最终链接有 ltsc 的
# 例如查找 windows 10 iot enterprise,会得到
@@ -689,9 +692,8 @@ get_windows_iso_link() {
for regex in "${regexs[@]}"; do
regex=${regex// /_}
- echo "finding: $regex" >&2
- if file=$(grep -Eix "$regex" "$tmp/win.list" | get_shortest_line | grep .); then
- iso="https://drive.massgrave.dev/$file"
+ echo "looking for: $regex" >&2
+ if iso=$(grep -Ei "/$regex" "$tmp/win.list" | get_shortest_line | grep .); then
return
fi
done
@@ -759,22 +761,25 @@ setos() {
if is_in_china; then
cdimage_mirror=https://mirrors.ustc.edu.cn/debian-cdimage
else
- cdimage_mirror=https://cdimage.debian.org/images
+ cdimage_mirror=https://cdimage.debian.org/images # 在瑞典,不是 cdn
+ # cloud.debian.org 同样在瑞典,不是 cdn
fi
if is_use_cloud_image; then
# cloud image
is_virt && ci_type=genericcloud || ci_type=generic
# 甲骨文 debian 10 amd64 genericcloud vnc 没有显示
- [ "$releasever" -eq 10 ] && [ "$basearch_alt" = amd64 ] && ci_type=generic
+ # 甲骨文 debian 10 arm64 没有 genericcloud 镜像
+ [ "$releasever" -eq 10 ] && ci_type=generic
eval ${step}_img=$cdimage_mirror/cloud/$codename/latest/debian-$releasever-$ci_type-$basearch_alt.qcow2
else
# 传统安装
if is_in_china; then
- # 部分国内机无法访问 ftp.cn.debian.org
+ # ftp.cn.debian.org 不在国内还严重丢包
+ # https://www.itdog.cn/ping/ftp.cn.debian.org
deb_hostname=mirrors.tuna.tsinghua.edu.cn
else
- deb_hostname=deb.debian.org
+ deb_hostname=deb.debian.org # fastly
fi
mirror=http://$deb_hostname/debian/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
@@ -800,7 +805,8 @@ setos() {
if is_in_china; then
deb_hostname=mirrors.tuna.tsinghua.edu.cn
else
- deb_hostname=kali.download
+ # http.kali.org (geoip 重定向) 到 kali.download (cf)
+ deb_hostname=http.kali.org
fi
codename=kali-rolling
mirror=http://$deb_hostname/kali/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
@@ -827,6 +833,12 @@ setos() {
if is_use_cloud_image; then
# cloud image
if is_in_china; then
+ # 有的源没有 releases 镜像
+ # https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/releases/
+ # https://unicom.mirrors.ustc.edu.cn/ubuntu-cloud-images/releases/
+ # https://mirror.nju.edu.cn/ubuntu-cloud-images/releases/
+
+ # mirrors.cloud.tencent.com
ci_mirror=https://mirror.nju.edu.cn/ubuntu-cloud-images
else
ci_mirror=https://cloud-images.ubuntu.com
@@ -869,14 +881,14 @@ setos() {
if is_in_china; then
mirror=https://mirrors.tuna.tsinghua.edu.cn/archlinux
else
- mirror=https://geo.mirror.pkgbuild.com
+ mirror=https://geo.mirror.pkgbuild.com # geoip
fi
else
if is_in_china; then
mirror=https://mirrors.tuna.tsinghua.edu.cn/archlinuxarm
else
# https 证书有问题
- mirror=http://mirror.archlinuxarm.org
+ mirror=http://mirror.archlinuxarm.org # geoip
fi
fi
@@ -898,8 +910,7 @@ setos() {
if is_in_china; then
mirror=https://mirrors.tuna.tsinghua.edu.cn/gentoo
else
- # mirror=https://mirror.leaseweb.com/gentoo # 不支持 ipv6
- mirror=https://distfiles.gentoo.org
+ mirror=https://distfiles.gentoo.org # cdn77
fi
if is_use_cloud_image; then
@@ -995,13 +1006,7 @@ setos() {
"8" | "9") ci_image=$ci_mirror/$releasever-stream/$basearch/images/CentOS-Stream-GenericCloud-$releasever-latest.$basearch.qcow2 ;;
esac
;;
- "alma")
- # alma8 x86_64 有独立的uefi镜像
- if [ "$releasever" = 8 ] && is_efi && [ "$basearch" = x86_64 ]; then
- alma_efi=-UEFI
- fi
- ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud$alma_efi-latest.$basearch.qcow2
- ;;
+ "alma") ci_image=$ci_mirror/AlmaLinux-$releasever-GenericCloud-latest.$basearch.qcow2 ;;
"rocky") ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;;
"fedora")
# Fedora-Cloud-Base-39-1.5.x86_64.qcow2
@@ -1128,11 +1133,11 @@ verify_os_name() {
'oracle 7|8|9' \
'alma 8|9' \
'rocky 8|9' \
- 'fedora 38|39|40' \
+ 'fedora 39|40' \
'debian 10|11|12' \
- 'ubuntu 20.04|22.04|24.04' \
- 'alpine 3.16|3.17|3.18|3.19' \
'opensuse 15.5|tumbleweed' \
+ 'ubuntu 20.04|22.04|24.04' \
+ 'alpine 3.17|3.18|3.19|3.20' \
'kali' \
'arch' \
'gentoo' \
@@ -1690,7 +1695,7 @@ add_efi_entry_in_linux() {
install_pkg efibootmgr
for efi_part in $(get_maybe_efi_dirs_in_linux); do
- if find $efi_part -name "*.efi" >/dev/null; then
+ if find $efi_part -iname "*.efi" >/dev/null; then
dist_dir=$efi_part/EFI/reinstall
basename=$(basename $source)
mkdir -p $dist_dir
@@ -1740,9 +1745,10 @@ install_grub_linux_efi() {
# 不要用 download.opensuse.org 和 download.fedoraproject.org
# 因为 ipv6 访问有时跳转到 ipv4 地址,造成 ipv6 only 机器无法下载
- # 日韩机器有时得到国内链接,且连不上
+ # 日韩机器有时得到国内镜像源,但镜像源屏蔽了国外 IP 导致连不上
+ # https://mirrors.bfsu.edu.cn/opensuse/ports/aarch64/tumbleweed/repo/oss/EFI/BOOT/grub.efi
if [ "$efi_distro" = fedora ]; then
- fedora_ver=39
+ fedora_ver=40
if is_in_china; then
mirror=https://mirrors.tuna.tsinghua.edu.cn/fedora
@@ -1770,6 +1776,8 @@ install_grub_win() {
# 下载 grub
info download grub
grub_ver=2.06
+ # ftpmirror.gnu.org 是 geoip 重定向,不是 cdn
+ # 有可能重定义到一个拉黑了部分 IP 的服务器
is_in_china && grub_url=https://mirrors.tuna.tsinghua.edu.cn/gnu/grub/grub-$grub_ver-for-windows.zip ||
grub_url=https://ftpmirror.gnu.org/gnu/grub/grub-$grub_ver-for-windows.zip
curl -Lo $tmp/grub.zip $grub_url
@@ -1796,6 +1804,7 @@ install_grub_win() {
# efi
info install grub for efi
if [ "$basearch" = aarch64 ]; then
+ # 3.20 是 grub 2.12,可能会有问题
alpine_ver=3.19
is_in_china && mirror=http://mirrors.tuna.tsinghua.edu.cn/alpine || mirror=https://dl-cdn.alpinelinux.org/alpine
grub_efi_apk=$(curl -L $mirror/v$alpine_ver/main/aarch64/ | grep -oP 'grub-efi-.*?apk' | head -1)
@@ -2436,7 +2445,7 @@ mod_initrd() {
# 解压
# 先删除临时文件,避免之前运行中断有残留文件
- tmp_dir=$tmp/reinstall
+ tmp_dir=$tmp/initrd
mkdir_clear $tmp_dir
cd $tmp_dir
@@ -2562,7 +2571,7 @@ else
fi
# 整理参数
-if ! opts=$(getopt -n $0 -o "" --long ci,debug,hold:,sleep:,iso:,image-name:,img:,lang: -- "$@"); then
+if ! opts=$(getopt -n $0 -o "" --long ci,debug,hold:,sleep:,iso:,image-name:,img:,lang,commit: -- "$@"); then
usage_and_exit
fi
@@ -2570,6 +2579,10 @@ eval set -- "$opts"
# shellcheck disable=SC2034
while true; do
case "$1" in
+ --commit)
+ commit=$2
+ shift 2
+ ;;
--debug)
set -x
shift
@@ -2681,9 +2694,24 @@ esac
# gitee 不支持ipv6
# jsdelivr 有12小时缓存
# https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L31
-if [ -n "$github_proxy" ] && [[ "$confhome" = http*://raw.githubusercontent.com/* ]] && is_in_china; then
- confhome=${confhome/http:\/\//https:\/\/}
- confhome=${confhome/https:\/\/raw.githubusercontent.com/$github_proxy}
+if [ -n "$github_proxy" ] && [[ "$confhome" = http*://raw.githubusercontent.com/* ]]; then
+ # 未测试
+ if false; then
+ repo=$(echo $confhome | cut -d/ -f4,5)
+ branch=$(echo $confhome | cut -d/ -f6)
+ # 避免脚本更新时,文件不同步造成错误
+ if [ -z "$commit" ]; then
+ commit=$(curl -L https://api.github.com/repos/$repo/git/refs/heads/$branch |
+ grep '"sha"' | grep -Eo '[0-9a-f]{40}')
+ fi
+ # shellcheck disable=SC2001
+ confhome=$(echo "$confhome" | sed "s/main$/$commit/")
+ fi
+
+ if is_in_china; then
+ confhome=${confhome/http:\/\//https:\/\/}
+ confhome=${confhome/https:\/\/raw.githubusercontent.com/$github_proxy}
+ fi
fi
# 以下目标系统不需要两步安装
diff --git a/trans.sh b/trans.sh
index 078c0c9..7d512bf 100644
--- a/trans.sh
+++ b/trans.sh
@@ -112,7 +112,7 @@ download() {
apk add coreutils
fi
- # 阿里云源检测 user-agent 禁止 axel/aria2 下载
+ # 阿里云源限速,而且检测 user-agent 禁止 axel/aria2 下载
# aria2 默认 --max-tries 5
# 默认 --max-tries=5,但以下情况服务器出错,aria2不会重试,而是直接返回错误
@@ -395,10 +395,10 @@ get_netconf_to() {
# shellcheck disable=SC2154
# debian initrd 没有 xargs
case "$1" in
- slaac) echo "$ra" | grep 'Autonomous address conf' | grep Yes && res=1 || res=0 ;;
- dhcpv6) echo "$ra" | grep 'Stateful address conf' | grep Yes && res=1 || res=0 ;;
+ slaac) echo "$ra" | grep 'Autonomous address conf' | grep -q Yes && res=1 || res=0 ;;
+ dhcpv6) echo "$ra" | grep 'Stateful address conf' | grep -q Yes && res=1 || res=0 ;;
rdnss) res=$(echo "$ra" | grep 'Recursive DNS server' | cut -d: -f2-) ;;
- other) echo "$ra" | grep 'Stateful other conf' | grep Yes && res=1 || res=0 ;;
+ other) echo "$ra" | grep 'Stateful other conf' | grep -q Yes && res=1 || res=0 ;;
*) res=$(cat /dev/$1) ;;
esac
@@ -936,7 +936,7 @@ EOF
pacstrap -K $os_dir $pkgs
# dns
- cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
+ cp_resolv_conf $os_dir
# 挂载伪文件系统
mount_pseudo_fs $os_dir
@@ -982,7 +982,7 @@ EOF
apk del tar xz
# dns
- cp -f /etc/resolv.conf $os_dir/etc/resolv.conf
+ cp_resolv_conf $os_dir
# 挂载伪文件系统
mount_pseudo_fs $os_dir
@@ -1187,7 +1187,7 @@ EOF
apk del arch-install-scripts
# 删除 resolv.conf,不然 systemd-resolved 无法创建软链接
- rm -f $os_dir/etc/resolv.conf
+ rm_resolv_conf $os_dir
# 删除 swap
swapoff -a
@@ -1587,7 +1587,7 @@ download_cloud_init_config() {
if ! grep -w swap $os_dir/etc/fstab; then
# btrfs
# 目前只有 arch 和 fedora 镜像使用 btrfs
- # 等 fedora 38 cloud-init 升级到 v23.3 后删除
+ # 等 fedora 39 cloud-init 升级到 v23.3 后删除
if mount | grep 'on /os type btrfs'; then
insert_into_file $ci_file after '^runcmd:' <