mirror of
https://github.com/bin456789/reinstall.git
synced 2026-04-23 14:34:19 +08:00
Compare commits
15 Commits
57542c4cbf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae3ad40c75 | ||
|
|
2d676731bb | ||
|
|
93e83dfc58 | ||
|
|
e93d71680c | ||
|
|
f0fc83a060 | ||
|
|
07d8018db3 | ||
|
|
e104735538 | ||
|
|
43e226cc5c | ||
|
|
c6000c16ab | ||
|
|
8dd873d7dd | ||
|
|
41c4df9fdb | ||
|
|
f0b3a475fc | ||
|
|
5e2f46444c | ||
|
|
c784479408 | ||
|
|
ca11ab5ef8 |
@@ -23,3 +23,6 @@ charset = utf-8-bom
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[reinstall.sh]
|
||||
shell_variant = bash
|
||||
|
||||
2
.github/workflows/run_reinstall.yml
vendored
2
.github/workflows/run_reinstall.yml
vendored
@@ -39,6 +39,8 @@ jobs:
|
||||
${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz
|
||||
${{ matrix.command }} windows --image-name='Windows Server blah' --iso https://aka.ms/HCIReleaseImage
|
||||
|
||||
${{ matrix.command }} reset
|
||||
|
||||
# 测试失败例子
|
||||
# ${{ matrix.command }} wrong-os
|
||||
# ${{ matrix.command }} dd --img=https://github.com/
|
||||
|
||||
58
README.en.md
58
README.en.md
@@ -38,6 +38,7 @@ If this helped you, you can buy me a milk tea.
|
||||
- [Feature 3. One-click reboot to Alpine Live OS](#feature-3-reboot-to--alpine-live-os)
|
||||
- [Feature 4. One-click reboot to netboot.xyz](#feature-4-reboot-to--netbootxyz)
|
||||
- [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso)
|
||||
- [Cancel the reinstallation](#cancel-the-reinstallation)
|
||||
|
||||
## System Requirements
|
||||
|
||||
@@ -144,7 +145,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation.
|
||||
|
||||
- Username `root`. The script prompts for a password. If left blank, a random one is generated.
|
||||
- When installing the latest version, the version number does not need to be specified.
|
||||
@@ -231,7 +232,7 @@ bash reinstall.sh ubuntu --installer
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation.
|
||||
|
||||
- Supports `raw` and fixed-size `vhd` image formats. Either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`.
|
||||
- When deploy a Windows image, the system disk will be automatically expanded, and machines with a static IP will have their IP configured, and may take a few minutes after the first boot for the configuration to take effect.
|
||||
@@ -324,7 +325,7 @@ bash reinstall.sh netboot.xyz
|
||||
>
|
||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
||||
>
|
||||
> Data is priceless — please think twice before proceeding!
|
||||
> If the script was run by mistake, you can run `bash reinstall.sh reset` before rebooting to cancel the reinstallation operation.
|
||||
|
||||
- Username `administrator`. The script prompts for a password. If left blank, a random one is generated.
|
||||
- If remote login fails, try using the username `.\administrator`.
|
||||
@@ -336,15 +337,15 @@ bash reinstall.sh netboot.xyz
|
||||
|
||||
- Windows (Vista ~ 11)
|
||||
- Windows Server (2008 ~ 2025)
|
||||
- Windows Server Essentials \*
|
||||
- Windows Server (Semi) Annual Channel \*
|
||||
- Hyper-V Server \*
|
||||
- Azure Local (Azure Stack HCI) \*
|
||||
- Windows Server Essentials
|
||||
- Windows Server (Semi) Annual Channel
|
||||
- Hyper-V Server
|
||||
- Azure Local (Azure Stack HCI)
|
||||
|
||||
#### Method 1: Let the Script Automatically Search for ISO
|
||||
|
||||
- The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs.
|
||||
- Systems marked with \* do not support automatic ISO searching.
|
||||
- Only supports ISOs searching for Windows 10, 11, Server 2019, 2022, 2025.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
@@ -464,7 +465,7 @@ bash reinstall.sh windows \
|
||||
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
||||
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
||||
- Azure ([MANA Network Adapter][azure-mana])
|
||||
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
- Intel (VMD Storage Controller: [11th Gen Core][intel-vmd-gen11], [12th-15th Gen Core][intel-vmd-gen12-to-gen15], Network Adapter: [7][intel-nic-7], [8.x][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
|
||||
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||
@@ -478,13 +479,12 @@ bash reinstall.sh windows \
|
||||
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
|
||||
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
|
||||
[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
|
||||
[intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-vmd-gen11]: https://www.intel.com/content/www/us/en/download/849933/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-13th-gen-platforms.html
|
||||
[intel-vmd-gen12-to-gen15]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
|
||||
[intel-nic-8]: https://web.archive.org/web/20250501043104/https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html
|
||||
[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
|
||||
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
||||
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
||||
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
|
||||
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
||||
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
||||
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
||||
@@ -546,28 +546,24 @@ Most ARM machines support installing latest Windows 11.
|
||||
|
||||
During the installation process, you might encounter a black screen, and the serial console may display `ConvertPages: failed to find range`, but neither issue affects the installation.
|
||||
|
||||
| Compatibility | Cloud Provider | Instance Type | Issues |
|
||||
| ------------- | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | Alibaba Cloud | g6r, c6r | |
|
||||
| ✔️ | Alibaba Cloud | g8y, c8y, r8y | There is a chance of hanging at the boot logo during restart; forced reboot will resolve it. |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed.<br />Manual loading of GPU drivers is required after installation. |
|
||||
| ❌ | Google Cloud | t2a | Missing network card drivers |
|
||||
| Compatibility | Cloud Provider | Instance Type | Issues |
|
||||
| ------------- | -------------- | ----------------------- | ----------------------------------------------------------------------------------- |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | Alibaba Cloud | g6r, c6r, g8y, c8y, r8y | Might hanging at the boot logo during restart; forced reboot will resolve it. |
|
||||
| ❔ | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed. |
|
||||
| ❌ | Google Cloud | t2a | Missing network card drivers |
|
||||
|
||||
<details>
|
||||
### Cancel the reinstallation
|
||||
|
||||
<summary>Loading Graphics Driver on Oracle Cloud</summary>
|
||||
- If the script was run by mistake, you can run this command to cancel the reinstallation operation.
|
||||
- Must be run before rebooting.
|
||||
|
||||
Log in to the server using Remote Desktop, open Device Manager, locate the graphics card, select "Update Driver," and choose `Red Hat VirtIO GPU DOD controller` from the list. There's no need to download the drivers in advance.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
</details>
|
||||
```bash
|
||||
bash reinstall.sh reset
|
||||
```
|
||||
|
||||
## Parameter Format
|
||||
|
||||
|
||||
58
README.md
58
README.md
@@ -38,6 +38,7 @@
|
||||
- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
|
||||
- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
|
||||
- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
|
||||
- [取消重装](#取消重装)
|
||||
|
||||
## 系统要求
|
||||
|
||||
@@ -144,7 +145,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||
|
||||
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
||||
- 安装最新版可不输入版本号
|
||||
@@ -231,7 +232,7 @@ bash reinstall.sh ubuntu --installer
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||
|
||||
- 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`
|
||||
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
|
||||
@@ -324,7 +325,7 @@ bash reinstall.sh netboot.xyz
|
||||
>
|
||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||
>
|
||||
> 数据无价,请三思而后行!
|
||||
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||
|
||||
- 用户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
|
||||
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
||||
@@ -336,15 +337,15 @@ bash reinstall.sh netboot.xyz
|
||||
|
||||
- Windows (Vista ~ 11)
|
||||
- Windows Server (2008 ~ 2025)
|
||||
- Windows Server Essentials \*
|
||||
- Windows Server (Semi) Annual Channel \*
|
||||
- Hyper-V Server \*
|
||||
- Azure Local (Azure Stack HCI) \*
|
||||
- Windows Server Essentials
|
||||
- Windows Server (Semi) Annual Channel
|
||||
- Hyper-V Server
|
||||
- Azure Local (Azure Stack HCI)
|
||||
|
||||
#### 方法 1: 让脚本自动查找 ISO
|
||||
|
||||
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO,该网站专门提供官方 ISO 下载
|
||||
- 上面带 \* 的系统不支持自动查找 ISO
|
||||
- 只支持查找 Windows 10, 11, Server 2019, 2022, 2025 的 ISO
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
@@ -464,7 +465,7 @@ bash reinstall.sh windows \
|
||||
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
||||
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
||||
- Azure ([MANA 网卡][azure-mana])
|
||||
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-2008-r2], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
- Intel (VMD 存储控制器: [11代酷睿][intel-vmd-gen11], [12-15代酷睿][intel-vmd-gen12-to-gen15], 网卡: [7][intel-nic-7], [8.x][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||
|
||||
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||
@@ -478,13 +479,12 @@ bash reinstall.sh windows \
|
||||
[gcp-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
|
||||
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
|
||||
[azure-mana]: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows
|
||||
[intel-vmd]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-vmd-gen11]: https://www.intel.com/content/www/us/en/download/849933/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-13th-gen-platforms.html
|
||||
[intel-vmd-gen12-to-gen15]: https://www.intel.com/content/www/us/en/download/849936/intel-rapid-storage-technology-driver-installation-software-with-intel-optane-memory-12th-to-15th-gen-platforms.html
|
||||
[intel-nic-7]: https://www.intel.com/content/www/us/en/download/15590/intel-network-adapter-driver-for-windows-7-final-release.html
|
||||
[intel-nic-8]: https://web.archive.org/web/20250501043104/https://www.intel.com/content/www/us/en/download/16765/intel-network-adapter-driver-for-windows-8-final-release.html
|
||||
[intel-nic-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
|
||||
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
||||
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
||||
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
|
||||
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
||||
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
||||
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
||||
@@ -546,28 +546,24 @@ Windows Server 2025 SERVERDATACENTER
|
||||
|
||||
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
|
||||
|
||||
| 兼容性 | 云服务商 | 实例类型 | 问题 |
|
||||
| ------ | -------- | ------------- | ---------------------------------------------------------------------------- |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | 阿里云 | g6r, c6r | |
|
||||
| ✔️ | 阿里云 | g8y, c8y, r8y | 有几率重启时卡开机 Logo,强制重启即可 |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功<br />安装后还需要手动加载显卡驱动 |
|
||||
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
|
||||
| 兼容性 | 云服务商 | 实例类型 | 问题 |
|
||||
| ------ | -------- | ----------------------- | ------------------------------------------ |
|
||||
| ✔️ | Azure | B2pts_v2 | |
|
||||
| ✔️ | AWS | T4g | |
|
||||
| ✔️ | Scaleway | COPARM1 | |
|
||||
| ✔️ | Gcore | | |
|
||||
| ❔ | 阿里云 | g6r, c6r, g8y, c8y, r8y | 有几率重启时卡开机 Logo,强制重启即可 |
|
||||
| ❔ | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功 |
|
||||
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
|
||||
|
||||
<details>
|
||||
### 取消重装
|
||||
|
||||
<summary>甲骨文云加载显卡驱动</summary>
|
||||
- 如果不小心运行了脚本,可以运行以下命令取消重装
|
||||
- 需要在重启前运行
|
||||
|
||||
使用远程桌面登录到服务器,打开设备管理器,找到显卡,选择更新驱动,在列表中选择 `Red Hat VirtIO GPU DOD controller` 即可。不需要提前下载驱动。
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
</details>
|
||||
```bash
|
||||
bash reinstall.sh reset
|
||||
```
|
||||
|
||||
## 参数格式
|
||||
|
||||
|
||||
975
reinstall.sh
975
reinstall.sh
File diff suppressed because it is too large
Load Diff
246
trans.sh
246
trans.sh
@@ -1,6 +1,6 @@
|
||||
#!/bin/ash
|
||||
# shellcheck shell=dash
|
||||
# shellcheck disable=SC2086,SC3047,SC3036,SC3010,SC3001,SC3060
|
||||
# shellcheck disable=SC2086,SC3047,SC3036,SC3010,SC3001,SC3060,SC3015
|
||||
# alpine 默认使用 busybox ash
|
||||
# 注意 bash 和 ash 以下语句结果不同
|
||||
# [[ a = '*a' ]] && echo 1
|
||||
@@ -1161,11 +1161,12 @@ EOF
|
||||
# 额外的 IPv6 地址(子网不含网关的地址)
|
||||
get_netconf_to ipv6_extra_addrs
|
||||
if [ -n "$ipv6_extra_addrs" ]; then
|
||||
_old_ifs=$IFS; IFS=','
|
||||
for _addr in $ipv6_extra_addrs; do
|
||||
echo " post-up ip -6 addr add $_addr dev $ethx" >>$conf_file
|
||||
done
|
||||
IFS=$_old_ifs
|
||||
(
|
||||
IFS=','
|
||||
for _addr in $ipv6_extra_addrs; do
|
||||
echo " post-up ip -6 addr add $_addr dev $ethx" >>$conf_file
|
||||
done
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1262,6 +1263,13 @@ networking = {
|
||||
EOF
|
||||
|
||||
for ethx in $(get_eths); do
|
||||
# ipv4 使用 DHCP 时显式开启 useDHCP
|
||||
if is_dhcpv4; then
|
||||
cat <<EOF >>$conf_file
|
||||
interfaces.$ethx.useDHCP = true;
|
||||
EOF
|
||||
fi
|
||||
|
||||
# ipv4
|
||||
if is_staticv4; then
|
||||
get_netconf_to ipv4_addr
|
||||
@@ -2534,6 +2542,22 @@ is_xda_gt_2t() {
|
||||
[ "$disk_size" -gt "$disk_2t" ]
|
||||
}
|
||||
|
||||
is_ends_with_digit() {
|
||||
[[ "$1" =~ [0-9]$ ]]
|
||||
}
|
||||
|
||||
xda() {
|
||||
if [ -n "$1" ]; then
|
||||
if is_ends_with_digit "$xda"; then
|
||||
echo "${xda}p$1"
|
||||
else
|
||||
echo "${xda}$1"
|
||||
fi
|
||||
else
|
||||
echo "$xda"
|
||||
fi
|
||||
}
|
||||
|
||||
create_part() {
|
||||
# 除了 dd 都会用到
|
||||
info "Create Part"
|
||||
@@ -2548,7 +2572,6 @@ create_part() {
|
||||
# TODO: 先检测iso链接/各种链接
|
||||
# wipefs -a /dev/$xda
|
||||
|
||||
# xda*1 星号用于 nvme0n1p1 的字母 p
|
||||
# shellcheck disable=SC2154
|
||||
if [ "$distro" = windows ]; then
|
||||
if ! size_bytes=$(get_link_file_size "$iso"); then
|
||||
@@ -2581,10 +2604,10 @@ create_part() {
|
||||
set 3 msftdata on
|
||||
update_part
|
||||
|
||||
mkfs.fat -n efi /dev/$xda*1 #1 efi
|
||||
dd if=/dev/zero of="$(ls /dev/$xda*2)" bs=1M count=16 #2 msr
|
||||
mkfs.ntfs -f -F -L os /dev/$xda*3 #3 os
|
||||
mkfs.ntfs -f -F -L installer /dev/$xda*4 #4 installer
|
||||
mkfs.fat -n efi "/dev/$(xda 1)" #1 efi
|
||||
dd if=/dev/zero of="/dev/$(xda 2)" bs=1M count=16 #2 msr
|
||||
mkfs.ntfs -f -F -L os "/dev/$(xda 3)" #3 os
|
||||
mkfs.ntfs -f -F -L installer "/dev/$(xda 4)" #4 installer
|
||||
else
|
||||
# bios + mbr 启动盘最大可用 2t
|
||||
if is_xda_gt_2t; then
|
||||
@@ -2601,13 +2624,10 @@ create_part() {
|
||||
set 1 boot on
|
||||
update_part
|
||||
|
||||
mkfs.ntfs -f -F -L os /dev/$xda*1 #1 os
|
||||
mkfs.ntfs -f -F -L installer /dev/$xda*2 #2 installer
|
||||
mkfs.ntfs -f -F -L os "/dev/$(xda 1)" #1 os
|
||||
mkfs.ntfs -f -F -L installer "/dev/$(xda 2)" #2 installer
|
||||
fi
|
||||
elif [ "$distro" = fnos ]; then
|
||||
# 先用 100% 分区安装后再缩小没意义,因为小硬盘用 100% 还是装不了
|
||||
# 因此直接用用户输入的分区大小
|
||||
|
||||
# 1. 官方安装器对系统盘大小的定义包含引导分区大小
|
||||
# 2. 官方 efi 用的是 1MiB-100M,但我们用 1MiB-101MiB
|
||||
|
||||
@@ -2639,47 +2659,53 @@ create_part() {
|
||||
# The location 20480MiB is outside of the device /dev/vda.
|
||||
# 但是 100% 分区后 end 就是 20480MiB
|
||||
|
||||
os_part_end=${expect_m}MiB
|
||||
if [ "$expect_m" -ge "$max_can_use_m" ]; then
|
||||
echo "Expect size is equal/greater than max size. Setting to 100%"
|
||||
os_part_end=100%
|
||||
warn "Expect size is equal/greater than max size. Uses max size."
|
||||
NEED_SHRINK_FNOS_OS_PART=false
|
||||
FNOS_OS_PART_END_M=$max_can_use_m
|
||||
else
|
||||
NEED_SHRINK_FNOS_OS_PART=true
|
||||
FNOS_OS_PART_END_M=$expect_m
|
||||
fi
|
||||
|
||||
# 需关闭这几个特性,否则 grub 无法识别
|
||||
# fnos 的 grub 是 debian 11 的
|
||||
# 需关闭 metadata_csum_seed,否则 grub 会进入 grub rescue 模式,但 efi 下一切正常
|
||||
# orphan_file 不需要关,但是官方安装器安装的系统分区没有这个特性,因此我们也关闭它
|
||||
ext4_opts="-O ^metadata_csum_seed,^orphan_file"
|
||||
|
||||
if is_efi; then
|
||||
parted /dev/$xda -s -- \
|
||||
mklabel gpt \
|
||||
mkpart BOOT fat32 1MiB 101MiB \
|
||||
mkpart SYSTEM ext4 101MiB $os_part_end \
|
||||
mkpart SYSTEM ext4 101MiB 100% \
|
||||
set 1 esp on
|
||||
update_part
|
||||
|
||||
mkfs.fat /dev/$xda*1 #1 efi
|
||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer
|
||||
mkfs.fat "/dev/$(xda 1)" #1 efi
|
||||
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os + installer
|
||||
elif is_xda_gt_2t; then
|
||||
# bios > 2t
|
||||
# 官方安装器是 mkpart BOOT 1M 100M,无论 esp 或者 bios_grub 都用这个分区和大小
|
||||
parted /dev/$xda -s -- \
|
||||
mklabel gpt \
|
||||
mkpart BOOT ext4 1MiB 101MiB \
|
||||
mkpart SYSTEM ext4 101MiB $os_part_end \
|
||||
mkpart SYSTEM ext4 101MiB 100% \
|
||||
set 1 bios_grub on
|
||||
update_part
|
||||
|
||||
echo #1 bios_boot
|
||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer
|
||||
echo #1 bios_boot
|
||||
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os + installer
|
||||
else
|
||||
# bios
|
||||
parted /dev/$xda -s -- \
|
||||
mklabel msdos \
|
||||
mkpart primary 1MiB 101MiB \
|
||||
mkpart primary 101MiB $os_part_end \
|
||||
mkpart primary 101MiB 100% \
|
||||
set 2 boot on
|
||||
update_part
|
||||
|
||||
echo #1 官方安装有这个分区
|
||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer
|
||||
echo #1 官方安装有这个分区
|
||||
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os + installer
|
||||
fi
|
||||
elif is_use_cloud_image; then
|
||||
installer_part_size="$(get_cloud_image_part_size)"
|
||||
@@ -2699,9 +2725,9 @@ create_part() {
|
||||
set 1 esp on
|
||||
update_part
|
||||
|
||||
mkfs.fat -n efi /dev/$xda*1 #1 efi
|
||||
echo #2 os 用目标系统的格式化工具
|
||||
mkfs.ext4 -F -L installer /dev/$xda*3 #3 installer
|
||||
mkfs.fat -n efi "/dev/$(xda 1)" #1 efi
|
||||
echo #2 os 用目标系统的格式化工具
|
||||
mkfs.ext4 -F -L installer "/dev/$(xda 3)" #3 installer
|
||||
else
|
||||
parted /dev/$xda -s -- \
|
||||
mklabel gpt \
|
||||
@@ -2711,9 +2737,9 @@ create_part() {
|
||||
set 1 bios_grub on
|
||||
update_part
|
||||
|
||||
echo #1 bios_boot
|
||||
echo #2 os 用目标系统的格式化工具
|
||||
mkfs.ext4 -F -L installer /dev/$xda*3 #3 installer
|
||||
echo #1 bios_boot
|
||||
echo #2 os 用目标系统的格式化工具
|
||||
mkfs.ext4 -F -L installer "/dev/$(xda 3)" #3 installer
|
||||
fi
|
||||
else
|
||||
# 使用 dd qcow2
|
||||
@@ -2724,8 +2750,8 @@ create_part() {
|
||||
mkpart '" "' ext4 -$installer_part_size 100%
|
||||
update_part
|
||||
|
||||
mkfs.ext4 -F -L os /dev/$xda*1 #1 os
|
||||
mkfs.ext4 -F -L installer /dev/$xda*2 #2 installer
|
||||
mkfs.ext4 -F -L os "/dev/$(xda 1)" #1 os
|
||||
mkfs.ext4 -F -L installer "/dev/$(xda 2)" #2 installer
|
||||
fi
|
||||
elif [ "$distro" = alpine ] || [ "$distro" = arch ] || [ "$distro" = gentoo ] ||
|
||||
[ "$distro" = nixos ] || [ "$distro" = aosc ]; then
|
||||
@@ -2742,8 +2768,8 @@ create_part() {
|
||||
set 1 boot on
|
||||
update_part
|
||||
|
||||
mkfs.fat /dev/$xda*1 #1 efi
|
||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os
|
||||
mkfs.fat "/dev/$(xda 1)" #1 efi
|
||||
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os
|
||||
elif is_xda_gt_2t; then
|
||||
# bios > 2t
|
||||
parted /dev/$xda -s -- \
|
||||
@@ -2753,8 +2779,8 @@ create_part() {
|
||||
set 1 bios_grub on
|
||||
update_part
|
||||
|
||||
echo #1 bios_boot
|
||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os
|
||||
echo #1 bios_boot
|
||||
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os
|
||||
else
|
||||
# bios
|
||||
parted /dev/$xda -s -- \
|
||||
@@ -2763,7 +2789,7 @@ create_part() {
|
||||
set 1 boot on
|
||||
update_part
|
||||
|
||||
mkfs.ext4 -F $ext4_opts /dev/$xda*1 #1 os
|
||||
mkfs.ext4 -F $ext4_opts "/dev/$(xda 1)" #1 os
|
||||
fi
|
||||
else
|
||||
# 安装红帽系或ubuntu
|
||||
@@ -2796,9 +2822,9 @@ create_part() {
|
||||
set 1 boot on
|
||||
update_part
|
||||
|
||||
mkfs.fat -n efi /dev/$xda*1 #1 efi
|
||||
mkfs.ext4 -F -L os /dev/$xda*2 #2 os
|
||||
mkfs.ext4 -F -L installer $ext4_opts /dev/$xda*3 #2 installer
|
||||
mkfs.fat -n efi "/dev/$(xda 1)" #1 efi
|
||||
mkfs.ext4 -F -L os "/dev/$(xda 2)" #2 os
|
||||
mkfs.ext4 -F -L installer $ext4_opts "/dev/$(xda 3)" #2 installer
|
||||
elif is_xda_gt_2t; then
|
||||
# bios > 2t
|
||||
parted /dev/$xda -s -- \
|
||||
@@ -2809,9 +2835,9 @@ create_part() {
|
||||
set 1 bios_grub on
|
||||
update_part
|
||||
|
||||
echo #1 bios_boot
|
||||
mkfs.ext4 -F -L os /dev/$xda*2 #2 os
|
||||
mkfs.ext4 -F -L installer $ext4_opts /dev/$xda*3 #3 installer
|
||||
echo #1 bios_boot
|
||||
mkfs.ext4 -F -L os "/dev/$(xda 2)" #2 os
|
||||
mkfs.ext4 -F -L installer $ext4_opts "/dev/$(xda 3)" #3 installer
|
||||
else
|
||||
# bios
|
||||
parted /dev/$xda -s -- \
|
||||
@@ -2821,8 +2847,8 @@ create_part() {
|
||||
set 1 boot on
|
||||
update_part
|
||||
|
||||
mkfs.ext4 -F -L os /dev/$xda*1 #1 os
|
||||
mkfs.ext4 -F -L installer $ext4_opts /dev/$xda*2 #2 installer
|
||||
mkfs.ext4 -F -L os "/dev/$(xda 1)" #1 os
|
||||
mkfs.ext4 -F -L installer $ext4_opts "/dev/$(xda 2)" #2 installer
|
||||
fi
|
||||
update_part
|
||||
fi
|
||||
@@ -3544,8 +3570,8 @@ EOF
|
||||
wget https://deb.freexian.com/extended-lts/archive-key.gpg \
|
||||
-O $os_dir/etc/apt/trusted.gpg.d/freexian-archive-extended-lts.gpg
|
||||
|
||||
codename=$(grep '^VERSION_CODENAME=' $os_dir/etc/os-release | cut -d= -f2)
|
||||
# shellcheck disable=SC2154
|
||||
# shellcheck disable=SC1091
|
||||
codename=$({ . "$os_dir/etc/os-release" && echo "$VERSION_CODENAME"; })
|
||||
if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then
|
||||
cat <<EOF >$os_dir/etc/apt/sources.list.d/debian.sources
|
||||
Types: deb
|
||||
@@ -3884,7 +3910,7 @@ setup_nocloud() {
|
||||
|
||||
# 1. 配置 NoCloud-only datasource
|
||||
mkdir -p "$os_dir/etc/cloud/cloud.cfg.d"
|
||||
cat > "$os_dir/etc/cloud/cloud.cfg.d/99-datasource.cfg" << 'EOF'
|
||||
cat >"$os_dir/etc/cloud/cloud.cfg.d/99-datasource.cfg" <<'EOF'
|
||||
datasource_list: [ NoCloud, None ]
|
||||
datasource:
|
||||
NoCloud:
|
||||
@@ -3917,7 +3943,9 @@ modify_os_on_disk() {
|
||||
|
||||
mkdir -p /os
|
||||
# 按分区容量大到小,依次寻找系统分区
|
||||
for part in $(lsblk /dev/$xda*[0-9] --sort SIZE -no NAME | tac); do
|
||||
# lsblk /dev/mmcblk0* 会列出 mmcblk0boot0 mmcblk0boot1
|
||||
# lsblk /dev/mmcblk0 不会列出 mmcblk0boot0 mmcblk0boot1
|
||||
for part in $(lsblk /dev/$xda --filter 'TYPE == "part"' --sort SIZE -no NAME | tac); do
|
||||
# btrfs挂载的是默认子卷,如果没有默认子卷,挂载的是根目录
|
||||
# fedora 云镜像没有默认子卷,且系统在root子卷中
|
||||
if mount -o ro /dev/$part /os; then
|
||||
@@ -4447,7 +4475,7 @@ install_fnos() {
|
||||
|
||||
# 挂载 /os
|
||||
mkdir -p /os
|
||||
mount /dev/$xda*2 /os
|
||||
mount "/dev/$(xda 2)" /os
|
||||
|
||||
# 下载并挂载 iso
|
||||
mkdir -p /os/installer /iso
|
||||
@@ -4488,7 +4516,7 @@ install_fnos() {
|
||||
# 挂载 /os/boot/efi
|
||||
if is_efi; then
|
||||
mkdir -p /os/boot/efi
|
||||
mount -o "$(echo "$fstab_line_efi" | awk '{print $4}')" /dev/$xda*1 /os/boot/efi
|
||||
mount -o "$(echo "$fstab_line_efi" | awk '{print $4}')" "/dev/$(xda 1)" /os/boot/efi
|
||||
fi
|
||||
|
||||
# 复制系统
|
||||
@@ -4500,6 +4528,36 @@ install_fnos() {
|
||||
# 删除 installer (trimfs.tgz)
|
||||
rm -rf /os/installer
|
||||
|
||||
# 缩小分区
|
||||
if $NEED_SHRINK_FNOS_OS_PART; then
|
||||
info "Shrink fnos os partition"
|
||||
|
||||
# 取消挂载
|
||||
if is_efi; then
|
||||
umount /os/boot/efi
|
||||
fi
|
||||
umount /os
|
||||
|
||||
# 101M 是 efi + bios_grub 分区,即使 bios 引导飞牛官方安装器也会生成一个 100M 预留分区
|
||||
# 99M 是预留的文件系统和分区表的差值
|
||||
# 一共 200M
|
||||
apk add e2fsprogs-extra parted
|
||||
e2fsck -p -f "/dev/$(xda 2)"
|
||||
resize2fs "/dev/$(xda 2)" "$((FNOS_OS_PART_END_M - 200))M"
|
||||
update_part
|
||||
printf "yes" | parted /dev/$xda resizepart 2 "$((FNOS_OS_PART_END_M))MiB" ---pretend-input-tty
|
||||
update_part
|
||||
resize2fs "/dev/$(xda 2)"
|
||||
update_part
|
||||
apk del e2fsprogs-extra parted
|
||||
|
||||
# 重新挂载
|
||||
mount "/dev/$(xda 2)" /os
|
||||
if is_efi; then
|
||||
mount -o "$(echo "$fstab_line_efi" | awk '{print $4}')" "/dev/$(xda 1)" /os/boot/efi
|
||||
fi
|
||||
fi
|
||||
|
||||
# 挂载 proc sys dev
|
||||
mount_pseudo_fs /os
|
||||
|
||||
@@ -4519,7 +4577,7 @@ install_fnos() {
|
||||
# fstab
|
||||
{
|
||||
# /
|
||||
uuid=$(lsblk /dev/$xda*2 -no UUID)
|
||||
uuid=$(lsblk "/dev/$(xda 2)" -no UUID)
|
||||
echo "$fstab_line_os" | sed "s/%s/$uuid/"
|
||||
|
||||
# swapfile
|
||||
@@ -4528,7 +4586,7 @@ install_fnos() {
|
||||
|
||||
# /boot/efi
|
||||
if is_efi; then
|
||||
uuid=$(lsblk /dev/$xda*1 -no UUID)
|
||||
uuid=$(lsblk "/dev/$(xda 1)" -no UUID)
|
||||
echo "$fstab_line_efi" | sed "s/%s/$uuid/"
|
||||
fi
|
||||
} >$os_dir/etc/fstab
|
||||
@@ -4654,7 +4712,7 @@ install_qcow_by_copy() {
|
||||
if is_efi; then
|
||||
# centos/oracle 要创建efi条目
|
||||
if ! grep /boot/efi /os/etc/fstab; then
|
||||
efi_part_uuid=$(lsblk /dev/$xda*1 -no UUID)
|
||||
efi_part_uuid=$(lsblk "/dev/$(xda 1)" -no UUID)
|
||||
echo "UUID=$efi_part_uuid /boot/efi vfat $efi_mount_opts 0 0" >>/os/etc/fstab
|
||||
fi
|
||||
else
|
||||
@@ -4989,7 +5047,7 @@ EOF
|
||||
# 因为 24.04 fsuuid 对应 boot 分区
|
||||
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
||||
if is_efi; then
|
||||
os_uuid=$(lsblk -rno UUID /dev/$xda*2)
|
||||
os_uuid=$(lsblk -rno UUID "/dev/$(xda 2)")
|
||||
sed -Ei "s|[0-9a-f-]{36}|$os_uuid|i" $efi_grub_cfg
|
||||
|
||||
# 24.04 移除 boot 分区后,需要添加 /boot 路径
|
||||
@@ -5003,7 +5061,7 @@ EOF
|
||||
if [ -e $force_partuuid_cfg ]; then
|
||||
if is_virt; then
|
||||
# 更改写死的 partuuid
|
||||
os_part_uuid=$(lsblk -rno PARTUUID /dev/$xda*2)
|
||||
os_part_uuid=$(lsblk -rno PARTUUID "/dev/$(xda 2)")
|
||||
sed -i "s/^GRUB_FORCE_PARTUUID=.*/GRUB_FORCE_PARTUUID=$os_part_uuid/" $force_partuuid_cfg
|
||||
else
|
||||
# 独服不应该使用 initrdless boot
|
||||
@@ -5154,8 +5212,8 @@ EOF
|
||||
mount_nouuid /dev/$os_part /nbd/
|
||||
mount_pseudo_fs /nbd/
|
||||
case "$os_part_fstype" in
|
||||
ext4) chroot /nbd mkfs.ext4 -F -L "$os_part_label" -U "$os_part_uuid" /dev/$xda*2 ;;
|
||||
xfs) chroot /nbd mkfs.xfs -f -L "$os_part_label" -m uuid=$os_part_uuid /dev/$xda*2 ;;
|
||||
ext4) chroot /nbd mkfs.ext4 -F -L "$os_part_label" -U "$os_part_uuid" "/dev/$(xda 2)" ;;
|
||||
xfs) chroot /nbd mkfs.xfs -f -L "$os_part_label" -m uuid=$os_part_uuid "/dev/$(xda 2)" ;;
|
||||
esac
|
||||
umount -R /nbd/
|
||||
|
||||
@@ -5163,7 +5221,7 @@ EOF
|
||||
|
||||
# 创建并挂载 /os
|
||||
mkdir -p /os
|
||||
mount -o noatime /dev/$xda*2 /os/
|
||||
mount -o noatime "/dev/$(xda 2)" /os/
|
||||
|
||||
# 如果是 efi 则创建 /os/boot/efi
|
||||
# 如果镜像有 efi 分区也创建 /os/boot/efi,用于复制 efi 分区的文件
|
||||
@@ -5174,7 +5232,7 @@ EOF
|
||||
# 预先挂载 /os/boot/efi 因为可能 boot 和 efi 在同一个分区(openeuler 24.03 arm)
|
||||
# 复制 boot 时可以会复制 efi 的文件
|
||||
if is_efi; then
|
||||
mount -o $efi_mount_opts /dev/$xda*1 /os/boot/efi/
|
||||
mount -o $efi_mount_opts "/dev/$(xda 1)" /os/boot/efi/
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -5225,7 +5283,7 @@ EOF
|
||||
if is_efi && [ -n "$efi_part_uuid" ] && ! [ "$efi_part" = "$os_part" ]; then
|
||||
info "Copy efi partition uuid"
|
||||
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
|
||||
apk del mtools
|
||||
update_part
|
||||
fi
|
||||
@@ -5239,9 +5297,9 @@ EOF
|
||||
|
||||
# 重新挂载 /os /boot/efi
|
||||
info "Re-mount disk"
|
||||
mount -o noatime /dev/$xda*2 /os/
|
||||
mount -o noatime "/dev/$(xda 2)" /os/
|
||||
if is_efi; then
|
||||
mount -o $efi_mount_opts /dev/$xda*1 /os/boot/efi/
|
||||
mount -o $efi_mount_opts "/dev/$(xda 1)" /os/boot/efi/
|
||||
fi
|
||||
|
||||
# 创建 swap
|
||||
@@ -5461,22 +5519,22 @@ resize_after_install_cloud_image() {
|
||||
ext4)
|
||||
# debian ci
|
||||
apk add e2fsprogs-extra
|
||||
e2fsck -p -f /dev/$xda*$last_part_num
|
||||
resize2fs /dev/$xda*$last_part_num
|
||||
e2fsck -p -f "/dev/$(xda $last_part_num)"
|
||||
resize2fs "/dev/$(xda $last_part_num)"
|
||||
apk del e2fsprogs-extra
|
||||
;;
|
||||
xfs)
|
||||
# opensuse ci
|
||||
apk add xfsprogs-extra
|
||||
mount /dev/$xda*$last_part_num /os
|
||||
xfs_growfs /dev/$xda*$last_part_num
|
||||
mount "/dev/$(xda $last_part_num)" /os
|
||||
xfs_growfs "/dev/$(xda $last_part_num)"
|
||||
umount /os
|
||||
apk del xfsprogs-extra
|
||||
;;
|
||||
btrfs)
|
||||
# fedora ci
|
||||
apk add btrfs-progs
|
||||
mount /dev/$xda*$last_part_num /os
|
||||
mount "/dev/$(xda $last_part_num)" /os
|
||||
btrfs filesystem resize max /os
|
||||
umount /os
|
||||
apk del btrfs-progs
|
||||
@@ -5484,8 +5542,8 @@ resize_after_install_cloud_image() {
|
||||
ntfs)
|
||||
# windows dd
|
||||
apk add ntfs-3g-progs
|
||||
echo y | ntfsresize /dev/$xda*$last_part_num
|
||||
ntfsfix -d /dev/$xda*$last_part_num
|
||||
echo y | ntfsresize "/dev/$(xda $last_part_num)"
|
||||
ntfsfix -d "/dev/$(xda $last_part_num)"
|
||||
apk del ntfs-3g-progs
|
||||
;;
|
||||
esac
|
||||
@@ -5506,12 +5564,12 @@ mount_part_basic_layout() {
|
||||
|
||||
# 挂载系统分区
|
||||
mkdir -p $os_dir
|
||||
mount -t ext4 /dev/${xda}*${os_part_num} $os_dir
|
||||
mount -t ext4 "/dev/$(xda $os_part_num)" $os_dir
|
||||
|
||||
# 挂载 efi 分区
|
||||
if is_efi; then
|
||||
mkdir -p $efi_dir
|
||||
mount -t vfat -o umask=077 /dev/${xda}*1 $efi_dir
|
||||
mount -t vfat -o umask=077 "/dev/$(xda 1)" $efi_dir
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -5851,7 +5909,7 @@ install_windows() {
|
||||
while true; do
|
||||
# 匹配成功
|
||||
# 改成正确的大小写
|
||||
if matched_image_name=$(echo "$all_image_names" | grep -ix "$image_name"); then
|
||||
if matched_image_name=$(printf '%s\n' "$all_image_names" | grep -Fix "$image_name"); then
|
||||
image_name=$matched_image_name
|
||||
image_index=$(wiminfo "$iso_install_wim" "$image_name" | grep 'Index:' | awk '{print $NF}')
|
||||
break
|
||||
@@ -6062,13 +6120,14 @@ install_windows() {
|
||||
boot_dir=/os
|
||||
fi
|
||||
|
||||
# 复制启动相关的文件
|
||||
# efi 额外复制efi目录
|
||||
# 复制 iso 根目录 boot 开头的文件
|
||||
echo 'Copying boot files...'
|
||||
cp -r "$(get_path_in_correct_case /iso/boot)"* $boot_dir
|
||||
find /iso -maxdepth 1 -iname 'boot*' -exec cp -r {} "$boot_dir" \;
|
||||
|
||||
# efi 额外复制 iso 根目录 efi 文件夹
|
||||
if is_efi; then
|
||||
echo 'Copying efi files...'
|
||||
cp -r "$(get_path_in_correct_case /iso/efi)" $boot_dir
|
||||
find /iso -maxdepth 1 -type d -iname efi -exec cp -r {} "$boot_dir" \;
|
||||
fi
|
||||
|
||||
# 复制iso全部文件(除了boot.wim)到installer分区
|
||||
@@ -6476,9 +6535,9 @@ EOF
|
||||
|
||||
apk add msitools
|
||||
|
||||
# 8.4.3 的 xenbus 挑创建实例时的初始系统
|
||||
# 初始系统为 windows 的实例支持 8.4.3
|
||||
# 初始系统为 linux 的实例不支持 8.4.3
|
||||
# 8.4.3+ 的 xenbus 驱动挑创建实例时的初始系统
|
||||
# 初始系统为 windows 的实例支持 8.4.3+
|
||||
# 初始系统为 linux 的实例不支持 8.4.3+
|
||||
|
||||
# 初始系统为 linux + 安装 8.4.3
|
||||
# 如果用 msi 安装,则不会启用 xenbus,结果是能启动但无法上网
|
||||
@@ -6493,11 +6552,16 @@ EOF
|
||||
6.1) $support_sha256 && echo 8.3.5 || echo 8.3.2 ;;
|
||||
6.2 | 6.3)
|
||||
case "$hypervisor_vendor" in
|
||||
Microsoft) echo 8.4.3 ;; # 实例初始系统为 Windows,能使用 8.4.3
|
||||
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux,不能使用 8.4.3
|
||||
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux
|
||||
Microsoft) echo 8.4.3 ;; # 实例初始系统为 Windows
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
case "$hypervisor_vendor" in
|
||||
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux
|
||||
Microsoft) echo Latest ;; # 实例初始系统为 Windows
|
||||
esac
|
||||
;;
|
||||
*) echo Latest ;;
|
||||
esac
|
||||
)
|
||||
|
||||
@@ -7184,12 +7248,12 @@ EOF
|
||||
# 或者用 ms-sys
|
||||
apk add grub-bios
|
||||
# efi 下,强制安装 mbr 引导,需要添加 --target i386-pc
|
||||
grub-install --target i386-pc --boot-directory=/os/boot /dev/$xda
|
||||
cat <<EOF >/os/boot/grub/grub.cfg
|
||||
grub-install --target i386-pc --boot-directory="$(get_path_in_correct_case /os/boot)" /dev/$xda
|
||||
cat <<EOF >"$(get_path_in_correct_case /os/boot/grub/grub.cfg)"
|
||||
set timeout=5
|
||||
menuentry "reinstall" {
|
||||
search --no-floppy --label --set=root os
|
||||
ntldr /bootmgr
|
||||
ntldr /$(cd /os && get_path_in_correct_case bootmgr)
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
|
||||
BIN
windows-frpc.xml
BIN
windows-frpc.xml
Binary file not shown.
Reference in New Issue
Block a user