mirror of
https://github.com/bin456789/reinstall.git
synced 2026-04-24 23:14:15 +08:00
Compare commits
16 Commits
57542c4cbf
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22d7a9a238 | ||
|
|
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}]
|
[*.{yml,yaml}]
|
||||||
indent_size = 2
|
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 }} 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 }} windows --image-name='Windows Server blah' --iso https://aka.ms/HCIReleaseImage
|
||||||
|
|
||||||
|
${{ matrix.command }} reset
|
||||||
|
|
||||||
# 测试失败例子
|
# 测试失败例子
|
||||||
# ${{ matrix.command }} wrong-os
|
# ${{ matrix.command }} wrong-os
|
||||||
# ${{ matrix.command }} dd --img=https://github.com/
|
# ${{ matrix.command }} dd --img=https://github.com/
|
||||||
|
|||||||
62
README.en.md
62
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 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 4. One-click reboot to netboot.xyz](#feature-4-reboot-to--netbootxyz)
|
||||||
- [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso)
|
- [Feature 5. One-click reinstallation to Windows](#feature-5-install--windows-iso)
|
||||||
|
- [Cancel the reinstallation](#cancel-the-reinstallation)
|
||||||
|
|
||||||
## System Requirements
|
## System Requirements
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ The system requirements for the target system are as follows:
|
|||||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
||||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | Rolling | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 18.04 LTS - 26.04 LTS | 512 MB \* | 2 GB |
|
||||||
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
||||||
@@ -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)!
|
> 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.
|
- 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.
|
- When installing the latest version, the version number does not need to be specified.
|
||||||
@@ -167,7 +168,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
alpine 3.20|3.21|3.22|3.23
|
alpine 3.20|3.21|3.22|3.23
|
||||||
opensuse 15.6|16.0|tumbleweed
|
opensuse 15.6|16.0|tumbleweed
|
||||||
openeuler 20.03|22.03|24.03|25.09
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal]
|
||||||
kali
|
kali
|
||||||
arch
|
arch
|
||||||
gentoo
|
gentoo
|
||||||
@@ -231,7 +232,7 @@ bash reinstall.sh ubuntu --installer
|
|||||||
>
|
>
|
||||||
> This feature will erase **the entire hard disk** of the current system (including other partitions)!
|
> 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`.
|
- Supports `raw` and fixed-size `vhd` image formats. Either uncompressed or compressed as `.gz`, `.xz`, `.zst`, `.tar`, `.tar.gz`, `.tar.xz`, `.tar.zst`.
|
||||||
- When deploy a Windows image, the system disk will be automatically expanded, and machines with a static IP will have their IP configured, and may take a few minutes after the first boot for the configuration to take effect.
|
- When deploy a 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)!
|
> 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.
|
- 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`.
|
- If remote login fails, try using the username `.\administrator`.
|
||||||
@@ -336,15 +337,15 @@ bash reinstall.sh netboot.xyz
|
|||||||
|
|
||||||
- Windows (Vista ~ 11)
|
- Windows (Vista ~ 11)
|
||||||
- Windows Server (2008 ~ 2025)
|
- Windows Server (2008 ~ 2025)
|
||||||
- Windows Server Essentials \*
|
- Windows Server Essentials
|
||||||
- Windows Server (Semi) Annual Channel \*
|
- Windows Server (Semi) Annual Channel
|
||||||
- Hyper-V Server \*
|
- Hyper-V Server
|
||||||
- Azure Local (Azure Stack HCI) \*
|
- Azure Local (Azure Stack HCI)
|
||||||
|
|
||||||
#### Method 1: Let the Script Automatically Search for ISO
|
#### Method 1: Let the Script Automatically Search for ISO
|
||||||
|
|
||||||
- The script will search for ISOs from <https://massgrave.dev/genuine-installation-media>, a site that collects official ISOs.
|
- 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
|
||||||
bash reinstall.sh windows \
|
bash reinstall.sh windows \
|
||||||
@@ -464,7 +465,7 @@ bash reinstall.sh windows \
|
|||||||
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
||||||
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
||||||
- Azure ([MANA Network Adapter][azure-mana])
|
- Azure ([MANA Network Adapter][azure-mana])
|
||||||
- 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-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
[virtio-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-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
|
||||||
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
|
[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
|
[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-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-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
|
||||||
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
||||||
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
||||||
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
|
|
||||||
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
||||||
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
||||||
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
||||||
@@ -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.
|
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 |
|
| Compatibility | Cloud Provider | Instance Type | Issues |
|
||||||
| ------------- | -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| ------------- | -------------- | ----------------------- | ----------------------------------------------------------------------------------- |
|
||||||
| ✔️ | Azure | B2pts_v2 | |
|
| ✔️ | Azure | B2pts_v2 | |
|
||||||
| ✔️ | Alibaba Cloud | g6r, c6r | |
|
| ✔️ | AWS | T4g | |
|
||||||
| ✔️ | Alibaba Cloud | g8y, c8y, r8y | There is a chance of hanging at the boot logo during restart; forced reboot will resolve it. |
|
| ✔️ | Scaleway | COPARM1 | |
|
||||||
| ✔️ | AWS | T4g | |
|
| ✔️ | Gcore | | |
|
||||||
| ✔️ | Scaleway | COPARM1 | |
|
| ❔ | Alibaba Cloud | g6r, c6r, g8y, c8y, r8y | Might hanging at the boot logo during restart; forced reboot will resolve it. |
|
||||||
| ✔️ | Gcore | | |
|
| ❔ | Oracle Cloud | A1.Flex | Installation success is not guaranteed; newer instances are more likely to succeed. |
|
||||||
| ❔ | 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 |
|
||||||
| ❌ | 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.
|
```bash
|
||||||
|
bash reinstall.sh reset
|
||||||

|
```
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Parameter Format
|
## Parameter Format
|
||||||
|
|
||||||
|
|||||||
62
README.md
62
README.md
@@ -38,6 +38,7 @@
|
|||||||
- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
|
- [功能 3. 一键引导到 Alpine Live OS 内存系统](#功能-3-重启到--alpine-live-os内存系统)
|
||||||
- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
|
- [功能 4. 一键引导到 netboot.xyz](#功能-4-重启到--netbootxyz)
|
||||||
- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
|
- [功能 5. 一键重装到 Windows](#功能-5-安装--windows-iso)
|
||||||
|
- [取消重装](#取消重装)
|
||||||
|
|
||||||
## 系统要求
|
## 系统要求
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
| <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine | 3.20, 3.21, 3.22, 3.23 | 256 MB | 1 GB |
|
||||||
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://www.debian.org/favicon.ico" /> Debian | 9, 10, 11, 12, 13 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
|
| <img width="16" height="16" src="https://github.com/bin456789/reinstall/assets/7548515/f74b3d5b-085f-4df3-bcc9-8a9bd80bb16d" /> Kali | 滚动 | 256 MB | 1 ~ 1.5 GB ^ |
|
||||||
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 16.04 LTS - 24.04 LTS, 25.10 | 512 MB \* | 2 GB |
|
| <img width="16" height="16" src="https://documentation.ubuntu.com/server/_static/favicon.png" /> Ubuntu | 18.04 LTS - 26.04 LTS | 512 MB \* | 2 GB |
|
||||||
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://img.alicdn.com/imgextra/i1/O1CN01oJnJZg1yK4RzI4Rx2_!!6000000006559-2-tps-118-118.png" /> Anolis | 7, 8, 23 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9, 10 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
||||||
@@ -144,7 +145,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
|||||||
>
|
>
|
||||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||||
>
|
>
|
||||||
> 数据无价,请三思而后行!
|
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||||
|
|
||||||
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
- 用户名为 `root`,脚本会提示输入密码,不输入则使用随机密码
|
||||||
- 安装最新版可不输入版本号
|
- 安装最新版可不输入版本号
|
||||||
@@ -167,7 +168,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
alpine 3.20|3.21|3.22|3.23
|
alpine 3.20|3.21|3.22|3.23
|
||||||
opensuse 15.6|16.0|tumbleweed
|
opensuse 15.6|16.0|tumbleweed
|
||||||
openeuler 20.03|22.03|24.03|25.09
|
openeuler 20.03|22.03|24.03|25.09
|
||||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.10 [--minimal]
|
ubuntu 18.04|20.04|22.04|24.04|26.04 [--minimal]
|
||||||
kali
|
kali
|
||||||
arch
|
arch
|
||||||
gentoo
|
gentoo
|
||||||
@@ -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`
|
- 支持 `raw` 和固定大小的 `vhd` 镜像。未压缩或者压缩成 `.gz` `.xz` `.zst` `.tar` `.tar.gz` `.tar.xz` `.tar.zst`
|
||||||
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
|
- DD Windows 镜像时,会自动扩展系统盘,静态 IP 的机器会配置好 IP,可能首次开机几分钟后才生效
|
||||||
@@ -324,7 +325,7 @@ bash reinstall.sh netboot.xyz
|
|||||||
>
|
>
|
||||||
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
> 此功能会清除当前系统**整个硬盘**的全部数据(包含其它分区)!
|
||||||
>
|
>
|
||||||
> 数据无价,请三思而后行!
|
> 如果不小心运行了脚本,可以在重启前运行 `bash reinstall.sh reset` 取消重装
|
||||||
|
|
||||||
- 用户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
|
- 用户名为 `administrator`,脚本会提示输入密码,不输入则使用随机密码
|
||||||
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
||||||
@@ -336,15 +337,15 @@ bash reinstall.sh netboot.xyz
|
|||||||
|
|
||||||
- Windows (Vista ~ 11)
|
- Windows (Vista ~ 11)
|
||||||
- Windows Server (2008 ~ 2025)
|
- Windows Server (2008 ~ 2025)
|
||||||
- Windows Server Essentials \*
|
- Windows Server Essentials
|
||||||
- Windows Server (Semi) Annual Channel \*
|
- Windows Server (Semi) Annual Channel
|
||||||
- Hyper-V Server \*
|
- Hyper-V Server
|
||||||
- Azure Local (Azure Stack HCI) \*
|
- Azure Local (Azure Stack HCI)
|
||||||
|
|
||||||
#### 方法 1: 让脚本自动查找 ISO
|
#### 方法 1: 让脚本自动查找 ISO
|
||||||
|
|
||||||
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO,该网站专门提供官方 ISO 下载
|
- 脚本会从 <https://massgrave.dev/genuine-installation-media> 查找 ISO,该网站专门提供官方 ISO 下载
|
||||||
- 上面带 \* 的系统不支持自动查找 ISO
|
- 只支持查找 Windows 10, 11, Server 2019, 2022, 2025 的 ISO
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash reinstall.sh windows \
|
bash reinstall.sh windows \
|
||||||
@@ -464,7 +465,7 @@ bash reinstall.sh windows \
|
|||||||
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
||||||
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
||||||
- Azure ([MANA 网卡][azure-mana])
|
- Azure ([MANA 网卡][azure-mana])
|
||||||
- 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-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
[virtio-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-gvnic]: https://cloud.google.com/compute/docs/networking/using-gvnic
|
||||||
[gcp-gga]: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display
|
[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
|
[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-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-8.1]: https://www.intel.com/content/www/us/en/download/17479/intel-network-adapter-driver-for-windows-8-1.html
|
||||||
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
[intel-nic-10]: https://www.intel.com/content/www/us/en/download/18293/intel-network-adapter-driver-for-windows-10.html
|
||||||
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
[intel-nic-11]: https://www.intel.com/content/www/us/en/download/727998/intel-network-adapter-driver-for-microsoft-windows-11.html
|
||||||
[intel-nic-2008-r2]: https://web.archive.org/web/20250501002542/https://www.intel.com/content/www/us/en/download/15591/intel-network-adapter-driver-for-windows-server-2008-r2-final-release.html
|
|
||||||
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
[intel-nic-2012]: https://www.intel.com/content/www/us/en/download/16789/intel-network-adapter-driver-for-windows-server-2012.html
|
||||||
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
[intel-nic-2012-r2]: https://www.intel.com/content/www/us/en/download/17480/intel-network-adapter-driver-for-windows-server-2012-r2.html
|
||||||
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
[intel-nic-2016]: https://www.intel.com/content/www/us/en/download/18737/intel-network-adapter-driver-for-windows-server-2016.html
|
||||||
@@ -546,28 +546,24 @@ Windows Server 2025 SERVERDATACENTER
|
|||||||
|
|
||||||
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
|
安装过程可能会黑屏,串行控制台可能会显示 `ConvertPages: failed to find range`,均不影响正常安装
|
||||||
|
|
||||||
| 兼容性 | 云服务商 | 实例类型 | 问题 |
|
| 兼容性 | 云服务商 | 实例类型 | 问题 |
|
||||||
| ------ | -------- | ------------- | ---------------------------------------------------------------------------- |
|
| ------ | -------- | ----------------------- | ------------------------------------------ |
|
||||||
| ✔️ | Azure | B2pts_v2 | |
|
| ✔️ | Azure | B2pts_v2 | |
|
||||||
| ✔️ | 阿里云 | g6r, c6r | |
|
| ✔️ | AWS | T4g | |
|
||||||
| ✔️ | 阿里云 | g8y, c8y, r8y | 有几率重启时卡开机 Logo,强制重启即可 |
|
| ✔️ | Scaleway | COPARM1 | |
|
||||||
| ✔️ | AWS | T4g | |
|
| ✔️ | Gcore | | |
|
||||||
| ✔️ | Scaleway | COPARM1 | |
|
| ❔ | 阿里云 | g6r, c6r, g8y, c8y, r8y | 有几率重启时卡开机 Logo,强制重启即可 |
|
||||||
| ✔️ | Gcore | | |
|
| ❔ | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功 |
|
||||||
| ❔ | 甲骨文云 | A1.Flex | 不一定能安装成功,越新创建的实例越容易成功<br />安装后还需要手动加载显卡驱动 |
|
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
|
||||||
| ❌ | 谷歌云 | t2a | 缺少网卡驱动 |
|
|
||||||
|
|
||||||
<details>
|
### 取消重装
|
||||||
|
|
||||||
<summary>甲骨文云加载显卡驱动</summary>
|
- 如果不小心运行了脚本,可以运行以下命令取消重装
|
||||||
|
- 需要在重启前运行
|
||||||
|
|
||||||
使用远程桌面登录到服务器,打开设备管理器,找到显卡,选择更新驱动,在列表中选择 `Red Hat VirtIO GPU DOD controller` 即可。不需要提前下载驱动。
|
```bash
|
||||||
|
bash reinstall.sh reset
|
||||||

|
```
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## 参数格式
|
## 参数格式
|
||||||
|
|
||||||
|
|||||||
999
reinstall.sh
999
reinstall.sh
File diff suppressed because it is too large
Load Diff
378
trans.sh
378
trans.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/ash
|
#!/bin/ash
|
||||||
# shellcheck shell=dash
|
# shellcheck shell=dash
|
||||||
# shellcheck disable=SC2086,SC3047,SC3036,SC3010,SC3001,SC3060
|
# shellcheck disable=SC2086,SC3047,SC3036,SC3010,SC3001,SC3060,SC3015
|
||||||
# alpine 默认使用 busybox ash
|
# alpine 默认使用 busybox ash
|
||||||
# 注意 bash 和 ash 以下语句结果不同
|
# 注意 bash 和 ash 以下语句结果不同
|
||||||
# [[ a = '*a' ]] && echo 1
|
# [[ a = '*a' ]] && echo 1
|
||||||
@@ -1161,11 +1161,12 @@ EOF
|
|||||||
# 额外的 IPv6 地址(子网不含网关的地址)
|
# 额外的 IPv6 地址(子网不含网关的地址)
|
||||||
get_netconf_to ipv6_extra_addrs
|
get_netconf_to ipv6_extra_addrs
|
||||||
if [ -n "$ipv6_extra_addrs" ]; then
|
if [ -n "$ipv6_extra_addrs" ]; then
|
||||||
_old_ifs=$IFS; IFS=','
|
(
|
||||||
for _addr in $ipv6_extra_addrs; do
|
IFS=','
|
||||||
echo " post-up ip -6 addr add $_addr dev $ethx" >>$conf_file
|
for _addr in $ipv6_extra_addrs; do
|
||||||
done
|
echo " post-up ip -6 addr add $_addr dev $ethx" >>$conf_file
|
||||||
IFS=$_old_ifs
|
done
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -1262,6 +1263,13 @@ networking = {
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
for ethx in $(get_eths); do
|
for ethx in $(get_eths); do
|
||||||
|
# ipv4 使用 DHCP 时显式开启 useDHCP
|
||||||
|
if is_dhcpv4; then
|
||||||
|
cat <<EOF >>$conf_file
|
||||||
|
interfaces.$ethx.useDHCP = true;
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
# ipv4
|
# ipv4
|
||||||
if is_staticv4; then
|
if is_staticv4; then
|
||||||
get_netconf_to ipv4_addr
|
get_netconf_to ipv4_addr
|
||||||
@@ -2534,6 +2542,22 @@ is_xda_gt_2t() {
|
|||||||
[ "$disk_size" -gt "$disk_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() {
|
create_part() {
|
||||||
# 除了 dd 都会用到
|
# 除了 dd 都会用到
|
||||||
info "Create Part"
|
info "Create Part"
|
||||||
@@ -2548,7 +2572,6 @@ create_part() {
|
|||||||
# TODO: 先检测iso链接/各种链接
|
# TODO: 先检测iso链接/各种链接
|
||||||
# wipefs -a /dev/$xda
|
# wipefs -a /dev/$xda
|
||||||
|
|
||||||
# xda*1 星号用于 nvme0n1p1 的字母 p
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [ "$distro" = windows ]; then
|
if [ "$distro" = windows ]; then
|
||||||
if ! size_bytes=$(get_link_file_size "$iso"); then
|
if ! size_bytes=$(get_link_file_size "$iso"); then
|
||||||
@@ -2581,10 +2604,10 @@ create_part() {
|
|||||||
set 3 msftdata on
|
set 3 msftdata on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.fat -n efi /dev/$xda*1 #1 efi
|
mkfs.fat -n efi "/dev/$(xda 1)" #1 efi
|
||||||
dd if=/dev/zero of="$(ls /dev/$xda*2)" bs=1M count=16 #2 msr
|
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 os "/dev/$(xda 3)" #3 os
|
||||||
mkfs.ntfs -f -F -L installer /dev/$xda*4 #4 installer
|
mkfs.ntfs -f -F -L installer "/dev/$(xda 4)" #4 installer
|
||||||
else
|
else
|
||||||
# bios + mbr 启动盘最大可用 2t
|
# bios + mbr 启动盘最大可用 2t
|
||||||
if is_xda_gt_2t; then
|
if is_xda_gt_2t; then
|
||||||
@@ -2601,13 +2624,10 @@ create_part() {
|
|||||||
set 1 boot on
|
set 1 boot on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.ntfs -f -F -L os /dev/$xda*1 #1 os
|
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 installer "/dev/$(xda 2)" #2 installer
|
||||||
fi
|
fi
|
||||||
elif [ "$distro" = fnos ]; then
|
elif [ "$distro" = fnos ]; then
|
||||||
# 先用 100% 分区安装后再缩小没意义,因为小硬盘用 100% 还是装不了
|
|
||||||
# 因此直接用用户输入的分区大小
|
|
||||||
|
|
||||||
# 1. 官方安装器对系统盘大小的定义包含引导分区大小
|
# 1. 官方安装器对系统盘大小的定义包含引导分区大小
|
||||||
# 2. 官方 efi 用的是 1MiB-100M,但我们用 1MiB-101MiB
|
# 2. 官方 efi 用的是 1MiB-100M,但我们用 1MiB-101MiB
|
||||||
|
|
||||||
@@ -2639,47 +2659,53 @@ create_part() {
|
|||||||
# The location 20480MiB is outside of the device /dev/vda.
|
# The location 20480MiB is outside of the device /dev/vda.
|
||||||
# 但是 100% 分区后 end 就是 20480MiB
|
# 但是 100% 分区后 end 就是 20480MiB
|
||||||
|
|
||||||
os_part_end=${expect_m}MiB
|
|
||||||
if [ "$expect_m" -ge "$max_can_use_m" ]; then
|
if [ "$expect_m" -ge "$max_can_use_m" ]; then
|
||||||
echo "Expect size is equal/greater than max size. Setting to 100%"
|
warn "Expect size is equal/greater than max size. Uses max size."
|
||||||
os_part_end=100%
|
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
|
fi
|
||||||
|
|
||||||
# 需关闭这几个特性,否则 grub 无法识别
|
# fnos 的 grub 是 debian 11 的
|
||||||
|
# 需关闭 metadata_csum_seed,否则 grub 会进入 grub rescue 模式,但 efi 下一切正常
|
||||||
|
# orphan_file 不需要关,但是官方安装器安装的系统分区没有这个特性,因此我们也关闭它
|
||||||
ext4_opts="-O ^metadata_csum_seed,^orphan_file"
|
ext4_opts="-O ^metadata_csum_seed,^orphan_file"
|
||||||
|
|
||||||
if is_efi; then
|
if is_efi; then
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
mklabel gpt \
|
mklabel gpt \
|
||||||
mkpart BOOT fat32 1MiB 101MiB \
|
mkpart BOOT fat32 1MiB 101MiB \
|
||||||
mkpart SYSTEM ext4 101MiB $os_part_end \
|
mkpart SYSTEM ext4 101MiB 100% \
|
||||||
set 1 esp on
|
set 1 esp on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.fat /dev/$xda*1 #1 efi
|
mkfs.fat "/dev/$(xda 1)" #1 efi
|
||||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer
|
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os + installer
|
||||||
elif is_xda_gt_2t; then
|
elif is_xda_gt_2t; then
|
||||||
# bios > 2t
|
# bios > 2t
|
||||||
# 官方安装器是 mkpart BOOT 1M 100M,无论 esp 或者 bios_grub 都用这个分区和大小
|
# 官方安装器是 mkpart BOOT 1M 100M,无论 esp 或者 bios_grub 都用这个分区和大小
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
mklabel gpt \
|
mklabel gpt \
|
||||||
mkpart BOOT ext4 1MiB 101MiB \
|
mkpart BOOT ext4 1MiB 101MiB \
|
||||||
mkpart SYSTEM ext4 101MiB $os_part_end \
|
mkpart SYSTEM ext4 101MiB 100% \
|
||||||
set 1 bios_grub on
|
set 1 bios_grub on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
echo #1 bios_boot
|
echo #1 bios_boot
|
||||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer
|
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os + installer
|
||||||
else
|
else
|
||||||
# bios
|
# bios
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
mklabel msdos \
|
mklabel msdos \
|
||||||
mkpart primary 1MiB 101MiB \
|
mkpart primary 1MiB 101MiB \
|
||||||
mkpart primary 101MiB $os_part_end \
|
mkpart primary 101MiB 100% \
|
||||||
set 2 boot on
|
set 2 boot on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
echo #1 官方安装有这个分区
|
echo #1 官方安装有这个分区
|
||||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer
|
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os + installer
|
||||||
fi
|
fi
|
||||||
elif is_use_cloud_image; then
|
elif is_use_cloud_image; then
|
||||||
installer_part_size="$(get_cloud_image_part_size)"
|
installer_part_size="$(get_cloud_image_part_size)"
|
||||||
@@ -2699,9 +2725,9 @@ create_part() {
|
|||||||
set 1 esp on
|
set 1 esp on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.fat -n efi /dev/$xda*1 #1 efi
|
mkfs.fat -n efi "/dev/$(xda 1)" #1 efi
|
||||||
echo #2 os 用目标系统的格式化工具
|
echo #2 os 用目标系统的格式化工具
|
||||||
mkfs.ext4 -F -L installer /dev/$xda*3 #3 installer
|
mkfs.ext4 -F -L installer "/dev/$(xda 3)" #3 installer
|
||||||
else
|
else
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
mklabel gpt \
|
mklabel gpt \
|
||||||
@@ -2711,9 +2737,9 @@ create_part() {
|
|||||||
set 1 bios_grub on
|
set 1 bios_grub on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
echo #1 bios_boot
|
echo #1 bios_boot
|
||||||
echo #2 os 用目标系统的格式化工具
|
echo #2 os 用目标系统的格式化工具
|
||||||
mkfs.ext4 -F -L installer /dev/$xda*3 #3 installer
|
mkfs.ext4 -F -L installer "/dev/$(xda 3)" #3 installer
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# 使用 dd qcow2
|
# 使用 dd qcow2
|
||||||
@@ -2724,8 +2750,8 @@ create_part() {
|
|||||||
mkpart '" "' ext4 -$installer_part_size 100%
|
mkpart '" "' ext4 -$installer_part_size 100%
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.ext4 -F -L os /dev/$xda*1 #1 os
|
mkfs.ext4 -F -L os "/dev/$(xda 1)" #1 os
|
||||||
mkfs.ext4 -F -L installer /dev/$xda*2 #2 installer
|
mkfs.ext4 -F -L installer "/dev/$(xda 2)" #2 installer
|
||||||
fi
|
fi
|
||||||
elif [ "$distro" = alpine ] || [ "$distro" = arch ] || [ "$distro" = gentoo ] ||
|
elif [ "$distro" = alpine ] || [ "$distro" = arch ] || [ "$distro" = gentoo ] ||
|
||||||
[ "$distro" = nixos ] || [ "$distro" = aosc ]; then
|
[ "$distro" = nixos ] || [ "$distro" = aosc ]; then
|
||||||
@@ -2742,8 +2768,8 @@ create_part() {
|
|||||||
set 1 boot on
|
set 1 boot on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.fat /dev/$xda*1 #1 efi
|
mkfs.fat "/dev/$(xda 1)" #1 efi
|
||||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os
|
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os
|
||||||
elif is_xda_gt_2t; then
|
elif is_xda_gt_2t; then
|
||||||
# bios > 2t
|
# bios > 2t
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
@@ -2753,8 +2779,8 @@ create_part() {
|
|||||||
set 1 bios_grub on
|
set 1 bios_grub on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
echo #1 bios_boot
|
echo #1 bios_boot
|
||||||
mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os
|
mkfs.ext4 -F $ext4_opts "/dev/$(xda 2)" #2 os
|
||||||
else
|
else
|
||||||
# bios
|
# bios
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
@@ -2763,7 +2789,7 @@ create_part() {
|
|||||||
set 1 boot on
|
set 1 boot on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.ext4 -F $ext4_opts /dev/$xda*1 #1 os
|
mkfs.ext4 -F $ext4_opts "/dev/$(xda 1)" #1 os
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# 安装红帽系或ubuntu
|
# 安装红帽系或ubuntu
|
||||||
@@ -2796,9 +2822,9 @@ create_part() {
|
|||||||
set 1 boot on
|
set 1 boot on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.fat -n efi /dev/$xda*1 #1 efi
|
mkfs.fat -n efi "/dev/$(xda 1)" #1 efi
|
||||||
mkfs.ext4 -F -L os /dev/$xda*2 #2 os
|
mkfs.ext4 -F -L os "/dev/$(xda 2)" #2 os
|
||||||
mkfs.ext4 -F -L installer $ext4_opts /dev/$xda*3 #2 installer
|
mkfs.ext4 -F -L installer $ext4_opts "/dev/$(xda 3)" #2 installer
|
||||||
elif is_xda_gt_2t; then
|
elif is_xda_gt_2t; then
|
||||||
# bios > 2t
|
# bios > 2t
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
@@ -2809,9 +2835,9 @@ create_part() {
|
|||||||
set 1 bios_grub on
|
set 1 bios_grub on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
echo #1 bios_boot
|
echo #1 bios_boot
|
||||||
mkfs.ext4 -F -L os /dev/$xda*2 #2 os
|
mkfs.ext4 -F -L os "/dev/$(xda 2)" #2 os
|
||||||
mkfs.ext4 -F -L installer $ext4_opts /dev/$xda*3 #3 installer
|
mkfs.ext4 -F -L installer $ext4_opts "/dev/$(xda 3)" #3 installer
|
||||||
else
|
else
|
||||||
# bios
|
# bios
|
||||||
parted /dev/$xda -s -- \
|
parted /dev/$xda -s -- \
|
||||||
@@ -2821,8 +2847,8 @@ create_part() {
|
|||||||
set 1 boot on
|
set 1 boot on
|
||||||
update_part
|
update_part
|
||||||
|
|
||||||
mkfs.ext4 -F -L os /dev/$xda*1 #1 os
|
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 installer $ext4_opts "/dev/$(xda 2)" #2 installer
|
||||||
fi
|
fi
|
||||||
update_part
|
update_part
|
||||||
fi
|
fi
|
||||||
@@ -3544,8 +3570,8 @@ EOF
|
|||||||
wget https://deb.freexian.com/extended-lts/archive-key.gpg \
|
wget https://deb.freexian.com/extended-lts/archive-key.gpg \
|
||||||
-O $os_dir/etc/apt/trusted.gpg.d/freexian-archive-extended-lts.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=SC1091
|
||||||
# shellcheck disable=SC2154
|
codename=$({ . "$os_dir/etc/os-release" && echo "$VERSION_CODENAME"; })
|
||||||
if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then
|
if [ -f $os_dir/etc/apt/sources.list.d/debian.sources ]; then
|
||||||
cat <<EOF >$os_dir/etc/apt/sources.list.d/debian.sources
|
cat <<EOF >$os_dir/etc/apt/sources.list.d/debian.sources
|
||||||
Types: deb
|
Types: deb
|
||||||
@@ -3884,7 +3910,7 @@ setup_nocloud() {
|
|||||||
|
|
||||||
# 1. 配置 NoCloud-only datasource
|
# 1. 配置 NoCloud-only datasource
|
||||||
mkdir -p "$os_dir/etc/cloud/cloud.cfg.d"
|
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_list: [ NoCloud, None ]
|
||||||
datasource:
|
datasource:
|
||||||
NoCloud:
|
NoCloud:
|
||||||
@@ -3917,7 +3943,9 @@ modify_os_on_disk() {
|
|||||||
|
|
||||||
mkdir -p /os
|
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挂载的是默认子卷,如果没有默认子卷,挂载的是根目录
|
# btrfs挂载的是默认子卷,如果没有默认子卷,挂载的是根目录
|
||||||
# fedora 云镜像没有默认子卷,且系统在root子卷中
|
# fedora 云镜像没有默认子卷,且系统在root子卷中
|
||||||
if mount -o ro /dev/$part /os; then
|
if mount -o ro /dev/$part /os; then
|
||||||
@@ -4374,23 +4402,19 @@ chroot_apt_autoremove() {
|
|||||||
change_confs() {
|
change_confs() {
|
||||||
action=$1
|
action=$1
|
||||||
|
|
||||||
# 只有 16.04 有 01autoremove-kernels
|
file=$os_dir/etc/apt/apt.conf.d/01autoremove
|
||||||
# 16.04 结束支持后删除
|
case "$action" in
|
||||||
for conf in 01autoremove 01autoremove-kernels; do
|
change)
|
||||||
file=$os_dir/etc/apt/apt.conf.d/$conf
|
if [ -f $file ]; then
|
||||||
case "$action" in
|
sed -i.orig 's/VersionedKernelPackages/x/; s/NeverAutoRemove/x/' $file
|
||||||
change)
|
fi
|
||||||
if [ -f $file ]; then
|
;;
|
||||||
sed -i.orig 's/VersionedKernelPackages/x/; s/NeverAutoRemove/x/' $file
|
restore)
|
||||||
fi
|
if [ -f $file.orig ]; then
|
||||||
;;
|
mv $file.orig $file
|
||||||
restore)
|
fi
|
||||||
if [ -f $file.orig ]; then
|
;;
|
||||||
mv $file.orig $file
|
esac
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
change_confs change
|
change_confs change
|
||||||
@@ -4447,7 +4471,7 @@ install_fnos() {
|
|||||||
|
|
||||||
# 挂载 /os
|
# 挂载 /os
|
||||||
mkdir -p /os
|
mkdir -p /os
|
||||||
mount /dev/$xda*2 /os
|
mount "/dev/$(xda 2)" /os
|
||||||
|
|
||||||
# 下载并挂载 iso
|
# 下载并挂载 iso
|
||||||
mkdir -p /os/installer /iso
|
mkdir -p /os/installer /iso
|
||||||
@@ -4488,7 +4512,7 @@ install_fnos() {
|
|||||||
# 挂载 /os/boot/efi
|
# 挂载 /os/boot/efi
|
||||||
if is_efi; then
|
if is_efi; then
|
||||||
mkdir -p /os/boot/efi
|
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
|
fi
|
||||||
|
|
||||||
# 复制系统
|
# 复制系统
|
||||||
@@ -4500,6 +4524,36 @@ install_fnos() {
|
|||||||
# 删除 installer (trimfs.tgz)
|
# 删除 installer (trimfs.tgz)
|
||||||
rm -rf /os/installer
|
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
|
# 挂载 proc sys dev
|
||||||
mount_pseudo_fs /os
|
mount_pseudo_fs /os
|
||||||
|
|
||||||
@@ -4519,7 +4573,7 @@ install_fnos() {
|
|||||||
# fstab
|
# fstab
|
||||||
{
|
{
|
||||||
# /
|
# /
|
||||||
uuid=$(lsblk /dev/$xda*2 -no UUID)
|
uuid=$(lsblk "/dev/$(xda 2)" -no UUID)
|
||||||
echo "$fstab_line_os" | sed "s/%s/$uuid/"
|
echo "$fstab_line_os" | sed "s/%s/$uuid/"
|
||||||
|
|
||||||
# swapfile
|
# swapfile
|
||||||
@@ -4528,7 +4582,7 @@ install_fnos() {
|
|||||||
|
|
||||||
# /boot/efi
|
# /boot/efi
|
||||||
if is_efi; then
|
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/"
|
echo "$fstab_line_efi" | sed "s/%s/$uuid/"
|
||||||
fi
|
fi
|
||||||
} >$os_dir/etc/fstab
|
} >$os_dir/etc/fstab
|
||||||
@@ -4654,7 +4708,7 @@ install_qcow_by_copy() {
|
|||||||
if is_efi; then
|
if is_efi; then
|
||||||
# centos/oracle 要创建efi条目
|
# centos/oracle 要创建efi条目
|
||||||
if ! grep /boot/efi /os/etc/fstab; then
|
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
|
echo "UUID=$efi_part_uuid /boot/efi vfat $efi_mount_opts 0 0" >>/os/etc/fstab
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -4869,19 +4923,6 @@ EOF
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 16.04 arm64 镜像没有 grub 引导文件
|
|
||||||
if is_efi && ! [ -d $os_dir/boot/efi/EFI/ubuntu ]; then
|
|
||||||
chroot_apt_install $os_dir efibootmgr shim "grub-efi-$(get_axx64)"
|
|
||||||
# 创建 ubuntu 文件夹和 grubaa64.efi
|
|
||||||
DEBIAN_FRONTEND=noninteractive chroot $os_dir dpkg-reconfigure "grub-efi-$(get_axx64)"
|
|
||||||
|
|
||||||
cat <<EOF >"$os_dir/boot/efi/EFI/ubuntu/grub.cfg"
|
|
||||||
search.fs_uuid $os_part_uuid root
|
|
||||||
set prefix=(\$root)'/boot/grub'
|
|
||||||
configfile \$prefix/grub.cfg
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 避免 do-release-upgrade 时自动执行 dpkg-reconfigure grub-xx 但是 efi/biosgrub 分区不存在而导致报错
|
# 避免 do-release-upgrade 时自动执行 dpkg-reconfigure grub-xx 但是 efi/biosgrub 分区不存在而导致报错
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
chroot_apt_remove $os_dir $(is_efi && echo 'grub-pc' || echo 'grub-efi*' 'shim*')
|
chroot_apt_remove $os_dir $(is_efi && echo 'grub-pc' || echo 'grub-efi*' 'shim*')
|
||||||
@@ -4937,43 +4978,31 @@ EOF
|
|||||||
|
|
||||||
# 网络配置
|
# 网络配置
|
||||||
# 18.04+ netplan
|
# 18.04+ netplan
|
||||||
if is_have_cmd_on_disk $os_dir netplan; then
|
# 避免删除 cloud-init 后,minimal 镜像的 netplan.io 被 autoremove
|
||||||
# 避免删除 cloud-init 后,minimal 镜像的 netplan.io 被 autoremove
|
chroot $os_dir apt-mark manual netplan.io
|
||||||
chroot $os_dir apt-mark manual netplan.io
|
|
||||||
|
|
||||||
# 生成 cloud-init 网络配置
|
# 生成 cloud-init 网络配置
|
||||||
create_cloud_init_network_config $os_dir/net.cfg
|
create_cloud_init_network_config $os_dir/net.cfg
|
||||||
|
|
||||||
# ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理 onlink
|
# ubuntu 18.04 cloud-init 版本 23.1.2,因此不用处理 onlink
|
||||||
|
|
||||||
# 如果不是输出到 / 则不会生成 50-cloud-init.yaml
|
# 如果不是输出到 / 则不会生成 50-cloud-init.yaml
|
||||||
# 注意比较多了什么东西
|
# 注意比较多了什么东西
|
||||||
if false; then
|
if false; then
|
||||||
chroot $os_dir cloud-init devel net-convert \
|
chroot $os_dir cloud-init devel net-convert \
|
||||||
-p /net.cfg -k yaml -d /out -D ubuntu -O netplan
|
-p /net.cfg -k yaml -d /out -D ubuntu -O netplan
|
||||||
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/out/etc/netplan/50-cloud-init.yaml
|
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/out/etc/netplan/50-cloud-init.yaml
|
||||||
cp $os_dir/out/etc/netplan/50-cloud-init.yaml $os_dir/etc/netplan/
|
cp $os_dir/out/etc/netplan/50-cloud-init.yaml $os_dir/etc/netplan/
|
||||||
|
|
||||||
# 清理
|
# 清理
|
||||||
rm -rf $os_dir/net.cfg $os_dir/out
|
rm -rf $os_dir/net.cfg $os_dir/out
|
||||||
else
|
|
||||||
chroot $os_dir cloud-init devel net-convert \
|
|
||||||
-p /net.cfg -k yaml -d / -D ubuntu -O netplan
|
|
||||||
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/etc/netplan/50-cloud-init.yaml
|
|
||||||
|
|
||||||
# 清理
|
|
||||||
rm -rf $os_dir/net.cfg
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# 避免删除 cloud-init 后 ifupdown 被 autoremove
|
chroot $os_dir cloud-init devel net-convert \
|
||||||
chroot $os_dir apt-mark manual ifupdown
|
-p /net.cfg -k yaml -d / -D ubuntu -O netplan
|
||||||
|
sed -Ei "/^[[:space:]]+set-name:/d" $os_dir/etc/netplan/50-cloud-init.yaml
|
||||||
|
|
||||||
# 16.04 镜像用 ifupdown/networking 管理网络
|
# 清理
|
||||||
# 要安装 resolveconf,不然 /etc/resolv.conf 为空
|
rm -rf $os_dir/net.cfg
|
||||||
chroot_apt_install $os_dir resolvconf
|
|
||||||
ln -sf /run/resolvconf/resolv.conf $os_dir/etc/resolv.conf.orig
|
|
||||||
|
|
||||||
create_ifupdown_config $os_dir/etc/network/interfaces
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 自带的 60-cloudimg-settings.conf 禁止了 PasswordAuthentication
|
# 自带的 60-cloudimg-settings.conf 禁止了 PasswordAuthentication
|
||||||
@@ -4989,7 +5018,7 @@ EOF
|
|||||||
# 因为 24.04 fsuuid 对应 boot 分区
|
# 因为 24.04 fsuuid 对应 boot 分区
|
||||||
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
efi_grub_cfg=$os_dir/boot/efi/EFI/ubuntu/grub.cfg
|
||||||
if is_efi; then
|
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
|
sed -Ei "s|[0-9a-f-]{36}|$os_uuid|i" $efi_grub_cfg
|
||||||
|
|
||||||
# 24.04 移除 boot 分区后,需要添加 /boot 路径
|
# 24.04 移除 boot 分区后,需要添加 /boot 路径
|
||||||
@@ -5003,7 +5032,7 @@ EOF
|
|||||||
if [ -e $force_partuuid_cfg ]; then
|
if [ -e $force_partuuid_cfg ]; then
|
||||||
if is_virt; then
|
if is_virt; then
|
||||||
# 更改写死的 partuuid
|
# 更改写死的 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
|
sed -i "s/^GRUB_FORCE_PARTUUID=.*/GRUB_FORCE_PARTUUID=$os_part_uuid/" $force_partuuid_cfg
|
||||||
else
|
else
|
||||||
# 独服不应该使用 initrdless boot
|
# 独服不应该使用 initrdless boot
|
||||||
@@ -5154,8 +5183,8 @@ EOF
|
|||||||
mount_nouuid /dev/$os_part /nbd/
|
mount_nouuid /dev/$os_part /nbd/
|
||||||
mount_pseudo_fs /nbd/
|
mount_pseudo_fs /nbd/
|
||||||
case "$os_part_fstype" in
|
case "$os_part_fstype" in
|
||||||
ext4) chroot /nbd mkfs.ext4 -F -L "$os_part_label" -U "$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 ;;
|
xfs) chroot /nbd mkfs.xfs -f -L "$os_part_label" -m uuid=$os_part_uuid "/dev/$(xda 2)" ;;
|
||||||
esac
|
esac
|
||||||
umount -R /nbd/
|
umount -R /nbd/
|
||||||
|
|
||||||
@@ -5163,7 +5192,7 @@ EOF
|
|||||||
|
|
||||||
# 创建并挂载 /os
|
# 创建并挂载 /os
|
||||||
mkdir -p /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 分区也创建 /os/boot/efi,用于复制 efi 分区的文件
|
# 如果镜像有 efi 分区也创建 /os/boot/efi,用于复制 efi 分区的文件
|
||||||
@@ -5174,7 +5203,7 @@ EOF
|
|||||||
# 预先挂载 /os/boot/efi 因为可能 boot 和 efi 在同一个分区(openeuler 24.03 arm)
|
# 预先挂载 /os/boot/efi 因为可能 boot 和 efi 在同一个分区(openeuler 24.03 arm)
|
||||||
# 复制 boot 时可以会复制 efi 的文件
|
# 复制 boot 时可以会复制 efi 的文件
|
||||||
if is_efi; then
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -5225,7 +5254,7 @@ EOF
|
|||||||
if is_efi && [ -n "$efi_part_uuid" ] && ! [ "$efi_part" = "$os_part" ]; then
|
if is_efi && [ -n "$efi_part_uuid" ] && ! [ "$efi_part" = "$os_part" ]; then
|
||||||
info "Copy efi partition uuid"
|
info "Copy efi partition uuid"
|
||||||
apk add mtools
|
apk add mtools
|
||||||
mlabel -N "$(echo $efi_part_uuid | sed 's/-//')" -i /dev/$xda*1 ::$efi_part_label
|
mlabel -N "$(echo $efi_part_uuid | sed 's/-//')" -i "/dev/$(xda 1)" ::$efi_part_label
|
||||||
apk del mtools
|
apk del mtools
|
||||||
update_part
|
update_part
|
||||||
fi
|
fi
|
||||||
@@ -5239,9 +5268,9 @@ EOF
|
|||||||
|
|
||||||
# 重新挂载 /os /boot/efi
|
# 重新挂载 /os /boot/efi
|
||||||
info "Re-mount disk"
|
info "Re-mount disk"
|
||||||
mount -o noatime /dev/$xda*2 /os/
|
mount -o noatime "/dev/$(xda 2)" /os/
|
||||||
if is_efi; then
|
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
|
||||||
|
|
||||||
# 创建 swap
|
# 创建 swap
|
||||||
@@ -5461,22 +5490,22 @@ resize_after_install_cloud_image() {
|
|||||||
ext4)
|
ext4)
|
||||||
# debian ci
|
# debian ci
|
||||||
apk add e2fsprogs-extra
|
apk add e2fsprogs-extra
|
||||||
e2fsck -p -f /dev/$xda*$last_part_num
|
e2fsck -p -f "/dev/$(xda $last_part_num)"
|
||||||
resize2fs /dev/$xda*$last_part_num
|
resize2fs "/dev/$(xda $last_part_num)"
|
||||||
apk del e2fsprogs-extra
|
apk del e2fsprogs-extra
|
||||||
;;
|
;;
|
||||||
xfs)
|
xfs)
|
||||||
# opensuse ci
|
# opensuse ci
|
||||||
apk add xfsprogs-extra
|
apk add xfsprogs-extra
|
||||||
mount /dev/$xda*$last_part_num /os
|
mount "/dev/$(xda $last_part_num)" /os
|
||||||
xfs_growfs /dev/$xda*$last_part_num
|
xfs_growfs "/dev/$(xda $last_part_num)"
|
||||||
umount /os
|
umount /os
|
||||||
apk del xfsprogs-extra
|
apk del xfsprogs-extra
|
||||||
;;
|
;;
|
||||||
btrfs)
|
btrfs)
|
||||||
# fedora ci
|
# fedora ci
|
||||||
apk add btrfs-progs
|
apk add btrfs-progs
|
||||||
mount /dev/$xda*$last_part_num /os
|
mount "/dev/$(xda $last_part_num)" /os
|
||||||
btrfs filesystem resize max /os
|
btrfs filesystem resize max /os
|
||||||
umount /os
|
umount /os
|
||||||
apk del btrfs-progs
|
apk del btrfs-progs
|
||||||
@@ -5484,8 +5513,8 @@ resize_after_install_cloud_image() {
|
|||||||
ntfs)
|
ntfs)
|
||||||
# windows dd
|
# windows dd
|
||||||
apk add ntfs-3g-progs
|
apk add ntfs-3g-progs
|
||||||
echo y | ntfsresize /dev/$xda*$last_part_num
|
echo y | ntfsresize "/dev/$(xda $last_part_num)"
|
||||||
ntfsfix -d /dev/$xda*$last_part_num
|
ntfsfix -d "/dev/$(xda $last_part_num)"
|
||||||
apk del ntfs-3g-progs
|
apk del ntfs-3g-progs
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -5506,12 +5535,12 @@ mount_part_basic_layout() {
|
|||||||
|
|
||||||
# 挂载系统分区
|
# 挂载系统分区
|
||||||
mkdir -p $os_dir
|
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 分区
|
# 挂载 efi 分区
|
||||||
if is_efi; then
|
if is_efi; then
|
||||||
mkdir -p $efi_dir
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5851,7 +5880,7 @@ install_windows() {
|
|||||||
while true; do
|
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_name=$matched_image_name
|
||||||
image_index=$(wiminfo "$iso_install_wim" "$image_name" | grep 'Index:' | awk '{print $NF}')
|
image_index=$(wiminfo "$iso_install_wim" "$image_name" | grep 'Index:' | awk '{print $NF}')
|
||||||
break
|
break
|
||||||
@@ -6062,13 +6091,14 @@ install_windows() {
|
|||||||
boot_dir=/os
|
boot_dir=/os
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 复制启动相关的文件
|
# 复制 iso 根目录 boot 开头的文件
|
||||||
# efi 额外复制efi目录
|
|
||||||
echo 'Copying boot files...'
|
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
|
if is_efi; then
|
||||||
echo 'Copying efi files...'
|
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
|
fi
|
||||||
|
|
||||||
# 复制iso全部文件(除了boot.wim)到installer分区
|
# 复制iso全部文件(除了boot.wim)到installer分区
|
||||||
@@ -6476,9 +6506,9 @@ EOF
|
|||||||
|
|
||||||
apk add msitools
|
apk add msitools
|
||||||
|
|
||||||
# 8.4.3 的 xenbus 挑创建实例时的初始系统
|
# 8.4.3+ 的 xenbus 驱动挑创建实例时的初始系统
|
||||||
# 初始系统为 windows 的实例支持 8.4.3
|
# 初始系统为 windows 的实例支持 8.4.3+
|
||||||
# 初始系统为 linux 的实例不支持 8.4.3
|
# 初始系统为 linux 的实例不支持 8.4.3+
|
||||||
|
|
||||||
# 初始系统为 linux + 安装 8.4.3
|
# 初始系统为 linux + 安装 8.4.3
|
||||||
# 如果用 msi 安装,则不会启用 xenbus,结果是能启动但无法上网
|
# 如果用 msi 安装,则不会启用 xenbus,结果是能启动但无法上网
|
||||||
@@ -6493,11 +6523,16 @@ EOF
|
|||||||
6.1) $support_sha256 && echo 8.3.5 || echo 8.3.2 ;;
|
6.1) $support_sha256 && echo 8.3.5 || echo 8.3.2 ;;
|
||||||
6.2 | 6.3)
|
6.2 | 6.3)
|
||||||
case "$hypervisor_vendor" in
|
case "$hypervisor_vendor" in
|
||||||
Microsoft) echo 8.4.3 ;; # 实例初始系统为 Windows,能使用 8.4.3
|
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux
|
||||||
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux,不能使用 8.4.3
|
Microsoft) echo 8.4.3 ;; # 实例初始系统为 Windows
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
case "$hypervisor_vendor" in
|
||||||
|
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux
|
||||||
|
Microsoft) echo Latest ;; # 实例初始系统为 Windows
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*) echo Latest ;;
|
|
||||||
esac
|
esac
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -7184,12 +7219,12 @@ EOF
|
|||||||
# 或者用 ms-sys
|
# 或者用 ms-sys
|
||||||
apk add grub-bios
|
apk add grub-bios
|
||||||
# efi 下,强制安装 mbr 引导,需要添加 --target i386-pc
|
# efi 下,强制安装 mbr 引导,需要添加 --target i386-pc
|
||||||
grub-install --target i386-pc --boot-directory=/os/boot /dev/$xda
|
grub-install --target i386-pc --boot-directory="$(get_path_in_correct_case /os/boot)" /dev/$xda
|
||||||
cat <<EOF >/os/boot/grub/grub.cfg
|
cat <<EOF >"$(get_path_in_correct_case /os/boot/grub/grub.cfg)"
|
||||||
set timeout=5
|
set timeout=5
|
||||||
menuentry "reinstall" {
|
menuentry "reinstall" {
|
||||||
search --no-floppy --label --set=root os
|
search --no-floppy --label --set=root os
|
||||||
ntldr /bootmgr
|
ntldr /$(cd /os && get_path_in_correct_case bootmgr)
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
@@ -7273,32 +7308,25 @@ get_ubuntu_kernel_flavor() {
|
|||||||
# https://github.com/systemd/systemd/blob/main/src/basic/virt.c
|
# https://github.com/systemd/systemd/blob/main/src/basic/virt.c
|
||||||
# https://github.com/canonical/cloud-init/blob/main/tools/ds-identify
|
# https://github.com/canonical/cloud-init/blob/main/tools/ds-identify
|
||||||
# http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;hb=HEAD
|
# http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;hb=HEAD
|
||||||
if [ "$releasever" = 16.04 ]; then
|
|
||||||
|
# 这里有坑
|
||||||
|
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
|
||||||
|
# 但是 $(get_cloud_vendor) 运行在 subshell 里面
|
||||||
|
# subshell 运行结束后里面的变量就消失了
|
||||||
|
# 因此先运行 cache_dmi_and_virt
|
||||||
|
cache_dmi_and_virt
|
||||||
|
vendor="$(get_cloud_vendor)"
|
||||||
|
case "$vendor" in
|
||||||
|
aws | gcp | oracle | azure | ibm) echo $vendor ;;
|
||||||
|
*)
|
||||||
|
is_ubuntu_lts && suffix=-hwe-$releasever || suffix=
|
||||||
if is_virt; then
|
if is_virt; then
|
||||||
echo virtual-hwe-$releasever
|
echo virtual$suffix
|
||||||
else
|
else
|
||||||
echo generic-hwe-$releasever
|
echo generic$suffix
|
||||||
fi
|
fi
|
||||||
else
|
;;
|
||||||
# 这里有坑
|
esac
|
||||||
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
|
|
||||||
# 但是 $(get_cloud_vendor) 运行在 subshell 里面
|
|
||||||
# subshell 运行结束后里面的变量就消失了
|
|
||||||
# 因此先运行 cache_dmi_and_virt
|
|
||||||
cache_dmi_and_virt
|
|
||||||
vendor="$(get_cloud_vendor)"
|
|
||||||
case "$vendor" in
|
|
||||||
aws | gcp | oracle | azure | ibm) echo $vendor ;;
|
|
||||||
*)
|
|
||||||
is_ubuntu_lts && suffix=-hwe-$releasever || suffix=
|
|
||||||
if is_virt; then
|
|
||||||
echo virtual$suffix
|
|
||||||
else
|
|
||||||
echo generic$suffix
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_redhat_ubuntu() {
|
install_redhat_ubuntu() {
|
||||||
|
|||||||
BIN
windows-frpc.xml
BIN
windows-frpc.xml
Binary file not shown.
Reference in New Issue
Block a user