mirror of
https://github.com/bin456789/reinstall.git
synced 2026-04-24 23:14:15 +08:00
Compare commits
12 Commits
f0b3a475fc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22d7a9a238 | ||
|
|
ae3ad40c75 | ||
|
|
2d676731bb | ||
|
|
93e83dfc58 | ||
|
|
e93d71680c | ||
|
|
f0fc83a060 | ||
|
|
07d8018db3 | ||
|
|
e104735538 | ||
|
|
43e226cc5c | ||
|
|
c6000c16ab | ||
|
|
8dd873d7dd | ||
|
|
41c4df9fdb |
14
README.en.md
14
README.en.md
@@ -51,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.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://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://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 |
|
||||
@@ -168,7 +168,7 @@ bash reinstall.sh anolis 7|8|23
|
||||
alpine 3.20|3.21|3.22|3.23
|
||||
opensuse 15.6|16.0|tumbleweed
|
||||
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
|
||||
arch
|
||||
gentoo
|
||||
@@ -337,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 \
|
||||
|
||||
14
README.md
14
README.md
@@ -51,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.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://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://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 |
|
||||
@@ -168,7 +168,7 @@ bash reinstall.sh anolis 7|8|23
|
||||
alpine 3.20|3.21|3.22|3.23
|
||||
opensuse 15.6|16.0|tumbleweed
|
||||
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
|
||||
arch
|
||||
gentoo
|
||||
@@ -337,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 \
|
||||
|
||||
105
reinstall.sh
105
reinstall.sh
@@ -33,7 +33,9 @@ export LC_ALL=C
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
|
||||
|
||||
# 如果不是 bash 的话,继续执行会有语法错误,因此在这里判断是否 bash
|
||||
if [ -z "$BASH" ]; then
|
||||
if [ -z "$BASH" ] ||
|
||||
# el 的 sh 是 bash 运行在 posix 模式,依然有 $BASH 和 $BASH_VERSION
|
||||
{ [ -n "$BASH" ] && [ -n "$POSIXLY_CORRECT" ]; }; then
|
||||
if ! command -v bash >/dev/null; then
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
if ! apk add bash; then
|
||||
@@ -87,7 +89,7 @@ Usage: $reinstall_____ anolis 7|8|23
|
||||
alpine 3.20|3.21|3.22|3.23
|
||||
opensuse 15.6|16.0|tumbleweed
|
||||
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
|
||||
arch
|
||||
gentoo
|
||||
@@ -910,17 +912,7 @@ get_windows_iso_link() {
|
||||
get_label_msdn() {
|
||||
if [ -n "$server" ]; then
|
||||
case "$version" in
|
||||
2008 | '2008 r2')
|
||||
case "$edition" in
|
||||
serverweb | serverwebcore) echo _ ;;
|
||||
serverstandard | serverstandardcore) echo _ ;;
|
||||
serverenterprise | serverenterprisecore) echo _ ;;
|
||||
serverdatacenter | serverdatacentercore) echo _ ;;
|
||||
esac
|
||||
;;
|
||||
# massgrave 不提供 2012 下载
|
||||
'2012 r2' | \
|
||||
2016 | 2019 | 2022 | 2025)
|
||||
2019 | 2022 | 2025)
|
||||
case "$edition" in
|
||||
serverstandard | serverstandardcore) echo _ ;;
|
||||
serverdatacenter | serverdatacentercore) echo _ ;;
|
||||
@@ -929,39 +921,6 @@ get_windows_iso_link() {
|
||||
esac
|
||||
else
|
||||
case "$version" in
|
||||
vista)
|
||||
case "$edition" in
|
||||
starter)
|
||||
case "$arch_win" in
|
||||
x86) echo _ ;;
|
||||
esac
|
||||
;;
|
||||
homebasic | homepremium | ultimate) echo _ ;;
|
||||
business | enterprise) echo "$edition" ;;
|
||||
esac
|
||||
;;
|
||||
7)
|
||||
case "$edition" in
|
||||
starter)
|
||||
case "$arch_win" in
|
||||
x86) echo starter ;;
|
||||
esac
|
||||
;;
|
||||
homebasic)
|
||||
case "$arch_win" in
|
||||
x86) echo "home basic" ;;
|
||||
esac
|
||||
;;
|
||||
homepremium) echo "home premium" ;;
|
||||
professional | enterprise | ultimate) echo "$edition" ;;
|
||||
esac
|
||||
;;
|
||||
8 | 8.1)
|
||||
case "$edition" in
|
||||
'') echo _ ;; # windows 8.x core
|
||||
pro | enterprise) echo "$edition" ;;
|
||||
esac
|
||||
;;
|
||||
10)
|
||||
case "$edition" in
|
||||
home | 'home single language') echo consumer ;;
|
||||
@@ -975,9 +934,8 @@ get_windows_iso_link() {
|
||||
# iot
|
||||
'iot enterprise') echo 'iot enterprise' ;;
|
||||
# iot ltsc
|
||||
'iot enterprise ltsc 2019' | 'iot enterprise ltsc 2021') echo "$edition" ;;
|
||||
'iot enterprise ltsc 2021') echo "$edition" ;;
|
||||
# ltsc
|
||||
'enterprise 2015 ltsb' | 'enterprise 2016 ltsb' | 'enterprise ltsc 2019') echo "$edition" ;;
|
||||
'enterprise ltsc 2021')
|
||||
# arm64 的 enterprise ltsc 2021 要下载 iot enterprise ltsc 2021 iso
|
||||
case "$arch_win" in
|
||||
@@ -1038,13 +996,7 @@ get_windows_iso_link() {
|
||||
# win10 22h2 arm 有每月发布的 iso,因此不从 msdl 下载
|
||||
# win10/11 ltsc 没有每月发布的 iso,但是 msdl 没有 ltsc 版本
|
||||
get_label_msdl() {
|
||||
case "$version" in
|
||||
8.1)
|
||||
case "$edition" in
|
||||
'' | pro) echo _ ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
:
|
||||
}
|
||||
|
||||
get_page() {
|
||||
@@ -1056,7 +1008,7 @@ get_windows_iso_link() {
|
||||
echo server
|
||||
else
|
||||
case "$version" in
|
||||
vista | 7 | 8 | 8.1 | 10 | 11)
|
||||
10 | 11)
|
||||
echo "$version"
|
||||
;;
|
||||
esac
|
||||
@@ -1073,9 +1025,7 @@ get_windows_iso_link() {
|
||||
label_vlsc=$(get_label_vlsc)
|
||||
page=$(get_page)
|
||||
|
||||
if [ "$page" = vista ]; then
|
||||
page_url=https://massgrave.dev/windows_vista__links
|
||||
elif [ "$page" = server ]; then
|
||||
if [ "$page" = server ]; then
|
||||
page_url=https://massgrave.dev/windows-server-links
|
||||
else
|
||||
page_url=https://massgrave.dev/windows_${page}_links
|
||||
@@ -1359,12 +1309,11 @@ Continue?
|
||||
|
||||
setos_ubuntu() {
|
||||
case "$releasever" in
|
||||
16.04) codename=xenial ;;
|
||||
18.04) codename=bionic ;;
|
||||
20.04) codename=focal ;;
|
||||
22.04) codename=jammy ;;
|
||||
24.04) codename=noble ;;
|
||||
25.10) codename=questing ;; # non-lts
|
||||
26.04) codename=resolute ;;
|
||||
esac
|
||||
|
||||
if is_use_cloud_image; then
|
||||
@@ -1388,24 +1337,19 @@ Continue?
|
||||
[ "$basearch_alt" = amd64 ] || [ "${releasever%.*}" -ge 24 ]
|
||||
}
|
||||
|
||||
get_suffix() {
|
||||
if [ "$releasever" = 16.04 ]; then
|
||||
if is_efi; then
|
||||
echo -uefi1
|
||||
else
|
||||
echo -disk1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
basearch_img=$basearch_alt
|
||||
if [ "$basearch_alt" = amd64 ] && [ "${releasever%.*}" -ge 26 ] && is_cpu_supports_x86_64_v3; then
|
||||
basearch_img=amd64v3
|
||||
fi
|
||||
|
||||
if [ "$minimal" = 1 ]; then
|
||||
if ! is_have_minimal_image; then
|
||||
error_and_exit "Minimal cloud image is not available for $releasever $basearch_alt."
|
||||
fi
|
||||
eval ${step}_img="$ci_mirror/minimal/releases/$codename/release/ubuntu-$releasever-minimal-cloudimg-$basearch_alt$(get_suffix).img"
|
||||
eval ${step}_img="$ci_mirror/minimal/releases/$codename/release/ubuntu-$releasever-minimal-cloudimg-$basearch_img.img"
|
||||
else
|
||||
# 用 codename 而不是 releasever,可减少一次跳转
|
||||
eval ${step}_img="$ci_mirror/releases/$codename/release/ubuntu-$releasever-server-cloudimg-$basearch_alt$(get_suffix).img"
|
||||
eval ${step}_img="$ci_mirror/releases/$codename/release/ubuntu-$releasever-server-cloudimg-$basearch_img.img"
|
||||
fi
|
||||
else
|
||||
# 传统安装
|
||||
@@ -1976,7 +1920,7 @@ verify_os_name() {
|
||||
'opensuse 15.6|16.0|tumbleweed' \
|
||||
'alpine 3.20|3.21|3.22|3.23' \
|
||||
'openeuler 20.03|22.03|24.03|25.09' \
|
||||
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.10' \
|
||||
'ubuntu 18.04|20.04|22.04|24.04|26.04' \
|
||||
'redhat' \
|
||||
'kali' \
|
||||
'arch' \
|
||||
@@ -2321,7 +2265,7 @@ check_ram() {
|
||||
is_efi() {
|
||||
if is_in_windows; then
|
||||
# bcdedit | grep -qi '^path.*\.efi'
|
||||
mountvol | grep -q --text 'EFI'
|
||||
mountvol | grep -q -a 'EFI'
|
||||
else
|
||||
[ -d /sys/firmware/efi ]
|
||||
fi
|
||||
@@ -2372,7 +2316,7 @@ is_use_local_extlinux() {
|
||||
is_mbr_using_grub() {
|
||||
find_main_disk
|
||||
# 各发行版不一定自带 strings hexdump xxd od 命令
|
||||
head -c 440 /dev/$xda | grep --text -iq 'GRUB'
|
||||
head -c 440 /dev/$xda | grep -a -iq 'GRUB'
|
||||
}
|
||||
|
||||
to_upper() {
|
||||
@@ -2966,7 +2910,7 @@ install_grub_linux_efi() {
|
||||
info 'download grub efi'
|
||||
|
||||
# fedora 39 的 efi 无法识别 opensuse tumbleweed 的 xfs
|
||||
efi_distro=opensuse
|
||||
efi_distro=fedora
|
||||
|
||||
grub_efi=$(get_grub_efi_filename)
|
||||
|
||||
@@ -3116,7 +3060,7 @@ install_grub_win() {
|
||||
# 添加引导
|
||||
# 脚本可能不是首次运行,所以先删除原来的
|
||||
id='{1c41f649-1637-52f1-aea8-f96bfebeecc8}'
|
||||
bcdedit /enum all | grep --text $id && bcdedit /delete $id
|
||||
bcdedit /enum all | grep -a $id && bcdedit /delete $id
|
||||
bcdedit /create $id /d "$(get_entry_name)" /application bootsector
|
||||
bcdedit /set $id device partition=$c:
|
||||
bcdedit /set $id path \\g2ldr
|
||||
@@ -3918,7 +3862,7 @@ This script is outdated, please download reinstall.sh again.
|
||||
# -c Identical to "-H newc", use the new (SVR4)
|
||||
# portable format.If you wish the old portable
|
||||
# (ASCII) archive format, use "-H odc" instead.
|
||||
find . | cpio --quiet -o -H newc | gzip -1 >/reinstall-initrd
|
||||
find . | cpio --quiet -o -H newc -R 0:0 | gzip -1 >/reinstall-initrd
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
@@ -3964,7 +3908,6 @@ remove_useless_initrd_files() {
|
||||
net/wireless \
|
||||
net/bluetooth \
|
||||
drivers/hid \
|
||||
drivers/mmc \
|
||||
drivers/mtd \
|
||||
drivers/usb \
|
||||
drivers/ssb \
|
||||
@@ -4200,12 +4143,12 @@ remove_exist_reinstall() {
|
||||
remove_exist_reinstall_efi_dir
|
||||
|
||||
bcdedit /set '{fwbootmgr}' bootsequence '{bootmgr}'
|
||||
bcdedit /enum bootmgr | grep --text -B3 'reinstall' | awk '{print $2}' | grep '{.*}' |
|
||||
bcdedit /enum bootmgr | grep -a -B3 'reinstall' | awk '{print $2}' | grep '{.*}' |
|
||||
xargs -I {} cmd /c bcdedit /delete {}
|
||||
else
|
||||
# bios
|
||||
id='{1c41f649-1637-52f1-aea8-f96bfebeecc8}'
|
||||
if bcdedit /enum all | grep --text "$id"; then
|
||||
if bcdedit /enum all | grep -a "$id"; then
|
||||
bcdedit /delete "$id"
|
||||
fi
|
||||
fi
|
||||
|
||||
346
trans.sh
346
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
|
||||
@@ -1263,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
|
||||
@@ -2535,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"
|
||||
@@ -2549,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
|
||||
@@ -2582,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
|
||||
@@ -2602,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
|
||||
|
||||
@@ -2640,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)"
|
||||
@@ -2700,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 \
|
||||
@@ -2712,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
|
||||
@@ -2725,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
|
||||
@@ -2743,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 -- \
|
||||
@@ -2754,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 -- \
|
||||
@@ -2764,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
|
||||
@@ -2797,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 -- \
|
||||
@@ -2810,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 -- \
|
||||
@@ -2822,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
|
||||
@@ -3918,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
|
||||
@@ -4375,23 +4402,19 @@ chroot_apt_autoremove() {
|
||||
change_confs() {
|
||||
action=$1
|
||||
|
||||
# 只有 16.04 有 01autoremove-kernels
|
||||
# 16.04 结束支持后删除
|
||||
for conf in 01autoremove 01autoremove-kernels; do
|
||||
file=$os_dir/etc/apt/apt.conf.d/$conf
|
||||
case "$action" in
|
||||
change)
|
||||
if [ -f $file ]; then
|
||||
sed -i.orig 's/VersionedKernelPackages/x/; s/NeverAutoRemove/x/' $file
|
||||
fi
|
||||
;;
|
||||
restore)
|
||||
if [ -f $file.orig ]; then
|
||||
mv $file.orig $file
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
file=$os_dir/etc/apt/apt.conf.d/01autoremove
|
||||
case "$action" in
|
||||
change)
|
||||
if [ -f $file ]; then
|
||||
sed -i.orig 's/VersionedKernelPackages/x/; s/NeverAutoRemove/x/' $file
|
||||
fi
|
||||
;;
|
||||
restore)
|
||||
if [ -f $file.orig ]; then
|
||||
mv $file.orig $file
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
change_confs change
|
||||
@@ -4448,7 +4471,7 @@ install_fnos() {
|
||||
|
||||
# 挂载 /os
|
||||
mkdir -p /os
|
||||
mount /dev/$xda*2 /os
|
||||
mount "/dev/$(xda 2)" /os
|
||||
|
||||
# 下载并挂载 iso
|
||||
mkdir -p /os/installer /iso
|
||||
@@ -4489,7 +4512,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
|
||||
|
||||
# 复制系统
|
||||
@@ -4501,6 +4524,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
|
||||
|
||||
@@ -4520,7 +4573,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
|
||||
@@ -4529,7 +4582,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
|
||||
@@ -4655,7 +4708,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
|
||||
@@ -4870,19 +4923,6 @@ EOF
|
||||
done
|
||||
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 分区不存在而导致报错
|
||||
# shellcheck disable=SC2046
|
||||
chroot_apt_remove $os_dir $(is_efi && echo 'grub-pc' || echo 'grub-efi*' 'shim*')
|
||||
@@ -4938,43 +4978,31 @@ EOF
|
||||
|
||||
# 网络配置
|
||||
# 18.04+ netplan
|
||||
if is_have_cmd_on_disk $os_dir netplan; then
|
||||
# 避免删除 cloud-init 后,minimal 镜像的 netplan.io 被 autoremove
|
||||
chroot $os_dir apt-mark manual netplan.io
|
||||
# 避免删除 cloud-init 后,minimal 镜像的 netplan.io 被 autoremove
|
||||
chroot $os_dir apt-mark manual netplan.io
|
||||
|
||||
# 生成 cloud-init 网络配置
|
||||
create_cloud_init_network_config $os_dir/net.cfg
|
||||
# 生成 cloud-init 网络配置
|
||||
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
|
||||
# 注意比较多了什么东西
|
||||
if false; then
|
||||
chroot $os_dir cloud-init devel net-convert \
|
||||
-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
|
||||
cp $os_dir/out/etc/netplan/50-cloud-init.yaml $os_dir/etc/netplan/
|
||||
# 如果不是输出到 / 则不会生成 50-cloud-init.yaml
|
||||
# 注意比较多了什么东西
|
||||
if false; then
|
||||
chroot $os_dir cloud-init devel net-convert \
|
||||
-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
|
||||
cp $os_dir/out/etc/netplan/50-cloud-init.yaml $os_dir/etc/netplan/
|
||||
|
||||
# 清理
|
||||
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
|
||||
# 清理
|
||||
rm -rf $os_dir/net.cfg $os_dir/out
|
||||
else
|
||||
# 避免删除 cloud-init 后 ifupdown 被 autoremove
|
||||
chroot $os_dir apt-mark manual ifupdown
|
||||
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
|
||||
|
||||
# 16.04 镜像用 ifupdown/networking 管理网络
|
||||
# 要安装 resolveconf,不然 /etc/resolv.conf 为空
|
||||
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
|
||||
# 清理
|
||||
rm -rf $os_dir/net.cfg
|
||||
fi
|
||||
|
||||
# 自带的 60-cloudimg-settings.conf 禁止了 PasswordAuthentication
|
||||
@@ -4990,7 +5018,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 路径
|
||||
@@ -5004,7 +5032,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
|
||||
@@ -5155,8 +5183,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/
|
||||
|
||||
@@ -5164,7 +5192,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 分区的文件
|
||||
@@ -5175,7 +5203,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
|
||||
|
||||
@@ -5226,7 +5254,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
|
||||
@@ -5240,9 +5268,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
|
||||
@@ -5462,22 +5490,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
|
||||
@@ -5485,8 +5513,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
|
||||
@@ -5507,12 +5535,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
|
||||
}
|
||||
|
||||
@@ -5852,7 +5880,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
|
||||
@@ -6478,9 +6506,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,结果是能启动但无法上网
|
||||
@@ -6495,11 +6523,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
|
||||
)
|
||||
|
||||
@@ -7275,32 +7308,25 @@ get_ubuntu_kernel_flavor() {
|
||||
# https://github.com/systemd/systemd/blob/main/src/basic/virt.c
|
||||
# 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
|
||||
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
|
||||
echo virtual-hwe-$releasever
|
||||
echo virtual$suffix
|
||||
else
|
||||
echo generic-hwe-$releasever
|
||||
echo generic$suffix
|
||||
fi
|
||||
else
|
||||
# 这里有坑
|
||||
# $(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
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_redhat_ubuntu() {
|
||||
|
||||
BIN
windows-frpc.xml
BIN
windows-frpc.xml
Binary file not shown.
Reference in New Issue
Block a user