core: 支持原系统为 arm windows

This commit is contained in:
bin456789 2024-01-27 23:08:34 +08:00
parent d90fd569af
commit abda204a50
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
4 changed files with 297 additions and 215 deletions

View File

@ -2,97 +2,131 @@
[![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)](#reinstall)
[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat)](https://github.com/XAMPPRocky/tokei_rs)
One-click Reinstallation Script
One-click reinstallation script
[中文](README.md) | [English](README.en.md)
[中文](README.md) | English
## Highlights
- Default usage of official installation programs. In cases where the memory requirements of the installation program are not met, the official cloud image will be used.
- Excludes third-party links and self-made packages; all resources are fetched in real-time from the source site.
- Adapted for 512M + 5G small VPS, and supports installing Alpine on 256M VPS.
- Supports installing Windows using the official ISO (does not support ARM).
- Supports reinstalling Windows as Linux and vice versa.
- Supports BIOS, EFI, ARM (Windows installation not supported on ARM).
- Supports original system partition with LVM, Btrfs.
- Supports installing Alpine, Arch, openSUSE, Gentoo, and installing from these systems.
- Progress of DD and cloud image installation can be viewed through SSH, a browser, serial console, or background VNC.
- Contains extensive comments.
- By default, the official installation program is used. When the memory requirements of the installation program are not met, the official cloud image (Cloud Image) will be used.
- The script does not include third-party links or homemade packages; all resources are obtained in real-time from the source site.
- Compatible with 512M + 5G small servers and supports installing Alpine on 256M small servers.
- Supports installing Windows using the official ISO.
- Supports reinstalling Windows as Linux or Windows itself.
- Supports BIOS, EFI, ARM.
- The original system partition supports LVM, Btrfs.
- Supports installing Alpine, Arch, openSUSE, Gentoo, and can also install these systems from them.
- Progress of DD and cloud image installation can be viewed through SSH, browser, serial console, and background VNC.
- Includes many comments.
## Usage on Linux
## Download (Current system is Linux)
### Download
For users outside China:
```bash
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
```
### Download (from within China)
For users in China:
```bash
curl -O https://raw.fgit.cf/bin456789/reinstall/main/reinstall.sh
```
## Download (Current system is Windows)
First, disable the `Real-time Protection` feature of `Windows Defender`.
For users outside China:
```batch
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
```
For users in China:
```batch
certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat
```
[Unable to download?](#if-the-script-cannot-be-downloaded-under-windows)
## Usage
- The following examples are for running on Linux; for Windows, run `reinstall.bat` with the same parameters.
### Usage 1: Install Linux
Note: For machines with static IP, installing centos, alma, rocky, fedora, debian, ubuntu, requires adding the --ci parameter to force the use of the cloud mirror.
- For machines with static IP, install CentOS, Alma, Rocky, Fedora, Debian, Ubuntu, and add the --ci parameter to force the use of the cloud image.
```bash
bash reinstall.sh centos 7|8|9 (8|9 for stream versions)
bash reinstall.sh centos 7|8|9 (8|9 for the stream version)
alma 8|9
rocky 8|9
fedora 38|39
debian 10|11|12
ubuntu 20.04|22.04
alpine 3.16|3.17|3.18|3.19
opensuse 15.5|tumbleweed (supports cloud mirror only)
arch (supports only amd64 cloud mirror)
gentoo (supports only amd64 cloud mirror)
opensuse 15.5|tumbleweed (only supports cloud image)
arch (only supports amd64 cloud image)
gentoo (only supports amd64 cloud image)
If no version number is entered, it installs the latest version.
If no version number is entered, the latest version will be installed.
```
Optional parameters: --ci Force the use of the cloud mirror.
Parameters:
```bash
--ci Force the use of the cloud image
```
### Usage 2: DD
Supports gzip, xz formats.
- Supports gzip, xz formats.
Supports automatic configuration of static IP, system disk expansion.
- For machines with static IP, DD Windows, and the script will automatically configure the IP.
```bash
bash reinstall.sh dd --img=https://example.com/xxx.xz
bash reinstall.sh dd --img https://example.com/xxx.xz
```
### Usage 3: Restart to Alpine Rescue System (Live OS)
### Usage 3: Reboot to Alpine Rescue System (Live OS)
Can be connected via SSH to perform manual DD, modify partitions, manually install Arch Linux, and other operations.
- 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.
```bash
bash reinstall.sh alpine --hold=1
```
### Usage 4: Restart to netboot.xyz
### Usage 4: Reboot to [netboot.xyz](https://netboot.xyz/)
- Can install more systems using background VNC.
```bash
bash reinstall.sh netboot.xyz
```
![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif)
### Usage 5: Install Windows ISO
```bash
bash reinstall.sh windows \
--iso='https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' \
--image-name='Windows 10 Enterprise LTSC 2021'
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' \
--image-name 'Windows 10 Enterprise LTSC 2021'
```
#### Parameter Description
![windows installer](https://filestore.community.support.microsoft.com/api/images/67c13a8c-cee6-47cd-ae80-a55923875c83)
`--iso` Original image link without integrating VirtIO, Xen, AWS, GCP drivers.
Parameters:
`--image-name` Specifies the image to install, case insensitive, enclosed in quotes, for example:
`--iso` Original image link, no need to integrate VirtIO, Xen, AWS, GCP drivers.
`--image-name` Specify the image to install, case-insensitive, should be enclosed in quotes on both sides, for example:
```text
'Windows 7 Ultimate'
@ -101,111 +135,95 @@ bash reinstall.sh windows \
'Windows Server 2022 SERVERDATACENTER'
```
Use `Dism++` File menu > Open image file, select the iso to get the image name.
Use `Dism++` File menu > Open Image File, select the iso to be installed to get the image name.
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
#### Other Notes
1. Successfully tested systems: 7, 10, 11, 2022. Tested platforms: vultr (bios), oracle (efi), aws t2 (xen), aws t3 (nitro).
2. Supports 32/64-bit systems; UEFI machines only support 64-bit.
3. Can bypass Windows 11 hardware restrictions.
4. Tested not to support ARM.
5. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`: After installing this image, the `wsappx` process may occupy CPU for an extended period.
1. Supported systems:
- Windows Vista to Windows 11
- Windows Server 2008 to Windows Server 2022
- Windows Server variants, such as
- Windows Server Essentials
- Windows Server Annual Channel
- Hyper-V Server
- Azure Stack HCI
2. BIOS can be used for 32/64 bit, UEFI machines can only use 64-bit.
3. If the machine has a static IP, the IP will be automatically set after installation.
4. Can bypass Windows 11 hardware restrictions.
5. Supports Azure ARM (Hyper-V), does not support Oracle ARM (KVM).
6. 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`.
This is an issue with the image, and the solution is to install the `VCLibs` library.
<https://www.google.com/search?q=ltsc+wsappx>
6. The following websites contain iso links:
<https://archive.org>
7. The following website provides iso links.
<https://massgrave.dev/genuine-installation-media.html>
## Usage on Windows
Run `cmd` with administrator privileges.
If running `powershell`, switch to `cmd` first.
### Download
```batch
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
```
### Download (from within China)
```batch
certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat
```
### If unable to download
- Disable Windows Defender real-time protection.
- Update SSL root certificate.
```batch
certutil -generateSSTFromWU root.sst
certutil -addstore Root root.sst
```
- Save the following two files via 'Save link as' or use 'Remote Desktop' to copy:
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
### Usage
All functionalities available in Linux can be used on Windows, using parameters similar to those in Linux.
For example, to install centos 7:
```batch
reinstall.bat centos-7
```
## Memory Requirements
| System | Traditional Install | Cloud Image |
| -------------------------------- | ------------------- | ------------|
| Debian | 384M | 512M |
| Ubuntu | 1G | 512M |
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
| Alpine | 256M | - |
| openSUSE | - | 512M |
| Arch | - | 512M |
| Gentoo | - | 512M |
| Windows | 1G | - |
| System | Traditional Installation | Cloud Image |
| ------------------------------------- | ------------------------ | ----------- |
| Debian | 384M | 512M |
| Ubuntu | 1G | 512M |
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
| Alpine | 256M | - |
| openSUSE | - | 512M |
| Arch | - | 512M |
| Gentoo | - | 512M |
| Windows 8.1 (Server 2012 R2) or below | 512M | - |
| Windows 10 (Server 2016) or above | 1G | - |
## Network Requirements
For 'Installation Mode' installing Linux, DHCPv4 is required.
Install Linux using the `Install Mode` must have DHCPv4.
Other cases support static IP, IPv6 (including installing Alpine, cloud mirror, Windows iso, dd).
Other cases support static IP, IPv6 (including installing Alpine, Linux cloud image, Windows iso, dd).
No need to fill in the static IP address when running the script.
## Virtualization Requirements
Does not support OpenVZ, LXC virtual machines.
Not supported on OpenVZ, LXC virtual machines.
Please use <https://github.com/LloydAsp/OsMutation>.
## Default Passwords
| System | Username | Password |
| -------------------- | -------------- | -------- |
| Linux | root | 123@@@ |
| Windows (ISO install) | administrator | 123@@@ |
| System | Username | Password |
| ------------- | -------------- | -------------- |
| Linux | root | 123@@@ |
| Windows (iso) | administrator | 123@@@ |
| Windows (dd) | Image username | Image password |
## 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.
<https://aka.ms/easyfix51044>
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`.
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
## TODO
- Installation modes: Static IP, IPv6, multiple NICs.
- Install mode: Static IP, IPv6, multiple NICs
## Sponsor
## Promotion
[![DartNode](https://github.com/bin456789/reinstall/assets/7548515/7531e443-4069-4bf1-a40e-2e965f311e3f)](https://dartnode.com/)

197
README.md
View File

@ -2,42 +2,65 @@
[![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)](#reinstall)
[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code&style=flat)](https://github.com/XAMPPRocky/tokei_rs)
一键重装脚本
[中文](README.md) | [English](README.en.md)
中文 | [English](README.en.md)
## 亮点
- 默认使用官方安装程序,不满足安装程序内存要求时,将使用官方云镜像 (Cloud Image)
- 不含第三方链接和自制包,所有资源均实时从源站点获得
- 适配 512M + 5G 小鸡,并支持 256M 小鸡安装 Alpine
- 支持用官方 iso 安装 Windows (不支持 ARM)
- 支持用官方 iso 安装 Windows
- 支持 Windows 重装成 Linux也可重装 Windows
- 支持 BIOS、EFI、ARM (ARM 不支持安装 Windows)
- 支持 BIOS、EFI、ARM
- 原系统分区支持 LVM、Btrfs
- 支持安装 Alpine、Arch、openSUSE、Gentoo也可从这些系统安装
- 可通过 SSH、浏览器、串行控制台、后台 VNC 查看 DD、云镜像安装进度
- 有很多注释
## Linux 下使用
## 下载(当前系统是 Linux
### 下载
国外:
```bash
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
```
### 下载 (国内)
国内:
```bash
curl -O https://raw.fgit.cf/bin456789/reinstall/main/reinstall.sh
```
## 下载(当前系统是 Windows
先关闭 `Windows Defender``实时保护` 功能
国外:
```batch
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
```
国内:
```batch
certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat
```
[无法下载?](#如果-windows-下无法下载脚本)
## 使用
- 以下用法以 Linux 下运行为例
- Windows 下运行 `reinstall.bat`,参数相同
### 用法 1: 安装 Linux
注意:静态 IP 的机器安装 centos、alma、rocky、fedora、debian、ubuntu需添加参数 --ci 强制使用云镜像
- 静态 IP 的机器安装 centos、alma、rocky、fedora、debian、ubuntu需添加参数 --ci 强制使用云镜像
```bash
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
@ -52,43 +75,55 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
gentoo (只支持 amd64 云镜像)
不输入版本号,则安装最新版
```
可选参数: --ci 强制使用云镜像
参数:
```bash
--ci 强制使用云镜像
```
### 用法 2: DD
支持 gzip、xz 格式
- 支持 gzip、xz 格式
支持自动配置静态 IP、扩展系统盘
- 静态 IP 的机器 DD Windows会自动配置好 IP
```bash
bash reinstall.sh dd --img=https://example.com/xxx.xz
bash reinstall.sh dd --img https://example.com/xxx.xz
```
### 用法 3重启到 Alpine 救援系统 (Live OS)
### 用法 3: 重启到 Alpine 救援系统 (Live OS)
可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch Linux 等操作
- 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch / Gentoo 等操作
- 如果没有修改硬盘内容,再次重启将回到原系统
```bash
bash reinstall.sh alpine --hold=1
```
### 用法 4重启到 netboot.xyz
### 用法 4: 重启到 [netboot.xyz](https://netboot.xyz/)
- 可使用后台 VNC 安装更多系统
```bash
bash reinstall.sh netboot.xyz
```
![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif)
### 用法 5: 安装 Windows ISO
```bash
bash reinstall.sh windows \
--iso='https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' \
--image-name='Windows 10 Enterprise LTSC 2021'
--iso 'https://drive.massgrave.dev/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' \
--image-name 'Windows 10 Enterprise LTSC 2021'
```
#### 参数说明
![windows installer](https://filestore.community.support.microsoft.com/api/images/67c13a8c-cee6-47cd-ae80-a55923875c83)
参数:
`--iso` 原版镜像链接,无需集成 VirtIO、Xen、AWS、GCP 驱动
@ -105,87 +140,47 @@ bash reinstall.sh windows \
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
#### 其它说明
1. 测试成功的系统有 7 10 11 2022测试平台为 vultr (bios)、甲骨文 (efi)、aws t2 (xen)、aws t3 (nitro)
2. 支持 32/64 位系统UEFI 机器只支持 64 位
3. 可绕过 Windows 11 硬件限制
4. 实测不支持 ARM
5. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 此镜像安装后 `wsappx` 进程会长期占用 CPU
1. 支持的系统:
- Windows Vista 到 Windows 11
- Windows Server 2008 到 Windows Server 2022
- Windows Server 变体,例如
- Windows Server Essentials
- Windows Server Annual Channel
- Hyper-V Server
- Azure Stack HCI
2. BIOS 可使用 32/64 位UEFI 机器只可使用 64 位
3. 如果机器是静态 IP安装后会自动设置 IP
4. 可绕过 Windows 11 硬件限制
5. 支持 Azure ARM (Hyper-V),不支持甲骨文 ARM (KVM)
6. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 此镜像安装后 `wsappx` 进程会长期占用 CPU
这是镜像的问题,解决方法是安装 `VCLibs`
<https://www.google.com/search?q=ltsc+wsappx>
6. 以下网站可找到 iso 链接
<https://archive.org>
7. 以下网站可找到 iso 链接
<https://massgrave.dev/genuine-installation-media.html>
## Windows 下使用
管理员权限运行 `cmd`
如果运行的是 `powershell`,先进入 `cmd`
### 下载
```batch
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
```
### 下载(国内)
```batch
certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat
```
### 如果无法下载
- 关闭 Windows Defender 实时保护
- 更新 SSL 根证书
```batch
certutil -generateSSTFromWU root.sst
certutil -addstore Root root.sst
```
- `链接另存为``远程桌面` 复制以下两个文件
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
### 使用
所有功能均可在 Windows 下使用,参数和 Linux 下使用一样
以安装 centos 7 为例
```batch
reinstall.bat centos-7
```
## 内存要求
| 系统 | 传统安装 | 云镜像 |
| ------------------------------ | -------- | ------ |
| Debian | 384M | 512M |
| Ubuntu | 1G | 512M |
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
| Alpine | 256M | - |
| openSUSE | - | 512M |
| Arch | - | 512M |
| Gentoo | - | 512M |
| Windows | 1G | - |
| 系统 | 传统安装 | 云镜像 |
| ----------------------------------- | -------- | ------ |
| Debian | 384M | 512M |
| Ubuntu | 1G | 512M |
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
| Alpine | 256M | - |
| openSUSE | - | 512M |
| Arch | - | 512M |
| Gentoo | - | 512M |
| Windows 8.1 (Server 2012 R2) 或以下 | 512M | - |
| Windows 10 (Server 2016) 或以上 | 1G | - |
## 网络要求
`安装模式`安装 Linux 要有 DHCPv4
其他情况支持静态 IP、IPv6包括安装 Alpine、云镜像、Windows iso、dd
其他情况支持静态 IP、IPv6包括安装 Alpine、Linux 云镜像、Windows iso、dd
运行脚本时不需要填写静态 IP 地址
@ -197,15 +192,39 @@ reinstall.bat centos-7
## 默认密码
| 系统 | 用户名 | 密码 |
| ------------------ | ------------- | ------ |
| Linux | root | 123@@@ |
| Windows (iso 安装) | administrator | 123@@@ |
| 系统 | 用户名 | 密码 |
| ------------- | ------------- | -------- |
| Linux | root | 123@@@ |
| Windows (iso) | administrator | 123@@@ |
| Windows (dd) | 镜像用户名 | 镜像密码 |
## 如果 Windows 下无法下载脚本
可尝试以下几种方法
1. 关闭 Windows Defender 实时保护
2. Windows 7 安装此补丁启用 TLS 1.2
<https://aka.ms/easyfix51044>
3. 更新 SSL 根证书
```batch
certutil -generateSSTFromWU root.sst
certutil -addstore Root root.sst
```
4. 手动下载,通过 `远程桌面` 复制这两个文件
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
## TODO
- 安装模式:静态 IP、IPv6、多网卡
## 赞助
## 推广
[![DartNode](https://github.com/bin456789/reinstall/assets/7548515/7531e443-4069-4bf1-a40e-2e965f311e3f)](https://dartnode.com/)

View File

@ -49,17 +49,34 @@ set pkgs="curl,cpio,p7zip,bind-utils,ipcalc"
set tags=%tmp%\cygwin-installed-!pkgs!
if not exist !tags! (
:: 检查32/64位
wmic os get osarchitecture | findstr /c:"64" >nul
if !errorlevel! == 0 (
set arch=x86_64
:: win10 arm 支持运行 x86 软件
:: win11 arm 支持运行 x86 和 x86_64 软件
:: wmic os get osarchitecture
wmic ComputerSystem get SystemType | find "ARM" > nul
if not errorlevel 1 (
for /f "tokens=2 delims==" %%a in ('wmic os get BuildNumber /format:list ^| find "BuildNumber"') do set BuildNumber=%%a
if !BuildNumber! GEQ 22000 (
set CygwinArch=x86_64
) else (
set CygwinArch=x86
)
) else (
wmic ComputerSystem get SystemType | find "x64" > nul
if not errorlevel 1 (
set CygwinArch=x86_64
) else (
set CygwinArch=x86
)
)
if "!CygwinArch!" == "x86_64" (
set dir=/sourceware/cygwin
) else (
set arch=x86
set dir=/sourceware/cygwin-archive/20221123
)
:: 下载 Cygwin
call :download http://www.cygwin.com/setup-!arch!.exe %tmp%\setup-cygwin.exe
call :download http://www.cygwin.com/setup-!CygwinArch!.exe %tmp%\setup-cygwin.exe
:: 安装 Cygwin
set site=!mirror!!dir!

View File

@ -1092,12 +1092,12 @@ install_grub_win() {
grub_dir=/tmp/grub-$grub_ver-for-windows
grub=$grub_dir/grub
# 设置 grub 内嵌的模块
# 设置 grub 包含的模块
# 原系统是 windows因此不需要 ext2 lvm xfs btrfs
grub_modules+=" normal minicmd serial ls echo test cat reboot halt linux linux16 chain search all_video configfile"
grub_modules+=" normal minicmd serial ls echo test cat reboot halt linux chain search all_video configfile"
grub_modules+=" scsi part_msdos part_gpt fat ntfs ntfscomp lzopio xzio gzio zstd"
if ! is_efi; then
grub_modules+=" biosdisk"
grub_modules+=" biosdisk linux16"
fi
# 设置 grub prefix 为c盘根目录
@ -1109,8 +1109,19 @@ install_grub_win() {
if is_efi; then
# efi
info install grub for efi
$grub-mkimage -p $prefix -O x86_64-efi -o "$(cygpath -w $grub_dir/grubx64.efi)" $grub_modules
add_efi_entry_in_windows $grub_dir/grubx64.efi
if [ "$basearch" = aarch64 ]; then
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)
mkdir -p /tmp/grub-efi
curl -L "$mirror/v$alpine_ver/main/aarch64/$grub_efi_apk" | tar xz --warning=no-unknown-keyword -C /tmp/grub-efi/
cp -r /tmp/grub-efi/usr/lib/grub/arm64-efi/ $grub_dir
$grub-mkimage -p $prefix -O arm64-efi -o "$(cygpath -w $grub_dir/grubaa64.efi)" $grub_modules
add_efi_entry_in_windows $grub_dir/grubaa64.efi
else
$grub-mkimage -p $prefix -O x86_64-efi -o "$(cygpath -w $grub_dir/grubx64.efi)" $grub_modules
add_efi_entry_in_windows $grub_dir/grubx64.efi
fi
else
# bios
info install grub for bios
@ -1446,13 +1457,30 @@ if [ "$distro" = alpine ] && is_use_cloud_image; then
fi
# 检查硬件架构
# x86强制使用x64
# archlinux 云镜像没有 arch 命令
basearch=$(uname -m)
[ $basearch = i686 ] && basearch=x86_64
case "$basearch" in
"x86_64") basearch_alt=amd64 ;;
"aarch64") basearch_alt=arm64 ;;
if is_in_windows; then
# x86-based PC
# x64-based PC
# ARM-based PC
# ARM64-based PC
basearch=$(wmic ComputerSystem get SystemType /format:list |
grep '=' | cut -d= -f2 | cut -d- -f1)
else
# archlinux 云镜像没有 arch 命令
# https://en.wikipedia.org/wiki/Uname
basearch=$(uname -m)
fi
# 统一架构名称,并强制 64 位
case "$(echo $basearch | to_lower)" in
i?86 | x64 | x86* | amd64)
basearch=x86_64
basearch_alt=amd64
;;
arm* | aarch64)
basearch=aarch64
basearch_alt=arm64
;;
*) error_and_exit "Unsupported arch: $basearch" ;;
esac
# 设置国内代理