mirror of
https://github.com/bin456789/reinstall.git
synced 2025-10-03 13:34:53 +00:00
Compare commits
5 Commits
cf6b4c226d
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1afc1a0022 | ||
![]() |
cdf09d017f | ||
![]() |
8d55af091d | ||
![]() |
8689c45b07 | ||
![]() |
ce8a315a2e |
19
.github/workflows/run_reinstall.yml
vendored
19
.github/workflows/run_reinstall.yml
vendored
@@ -21,18 +21,19 @@ jobs:
|
||||
git config --global core.autocrlf false
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
${{ matrix.command }} centos
|
||||
${{ matrix.command }} almalinux 8
|
||||
${{ matrix.command }} rocky 9
|
||||
${{ matrix.command }} fedora
|
||||
# ${{ matrix.command }} centos
|
||||
${{ matrix.command }} almalinux
|
||||
# ${{ matrix.command }} rocky
|
||||
# ${{ matrix.command }} fedora
|
||||
# ${{ matrix.command }} oracle
|
||||
${{ matrix.command }} ubuntu
|
||||
${{ matrix.command }} debian
|
||||
${{ matrix.command }} debian --ci
|
||||
${{ matrix.command }} kali
|
||||
${{ matrix.command }} alpine
|
||||
${{ matrix.command }} opensuse
|
||||
${{ matrix.command }} arch
|
||||
${{ matrix.command }} gentoo
|
||||
# ${{ matrix.command }} kali
|
||||
# ${{ matrix.command }} alpine
|
||||
# ${{ matrix.command }} opensuse
|
||||
# ${{ matrix.command }} arch
|
||||
# ${{ matrix.command }} gentoo
|
||||
|
||||
${{ matrix.command }} netboot.xyz
|
||||
${{ matrix.command }} dd --img=https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-SelfInstall.raw.xz
|
||||
|
@@ -51,11 +51,11 @@ The system requirements for the target system are as follows:
|
||||
| <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.04 | 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 (if released) | 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://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | Rolling | 512 MB | 5 GB |
|
||||
@@ -155,7 +155,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
```bash
|
||||
bash reinstall.sh anolis 7|8|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
opencloudos 8|9|23
|
||||
centos 9|10
|
||||
@@ -164,7 +164,7 @@ bash reinstall.sh anolis 7|8|23
|
||||
debian 9|10|11|12|13
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.19|3.20|3.21|3.22
|
||||
openeuler 20.03|22.03|24.03|25.03
|
||||
openeuler 20.03|22.03|24.03|25.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||
kali
|
||||
arch
|
||||
|
@@ -51,11 +51,11 @@
|
||||
| <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.04 | 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://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://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.09 | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||
| <img width="16" height="16" src="https://nixos.org/favicon.svg" /> NixOS | 25.05 | 512 MB | 5 GB |
|
||||
| <img width="16" height="16" src="https://archlinux.org/static/favicon.png" /> Arch | 滚动 | 512 MB | 5 GB |
|
||||
@@ -155,7 +155,7 @@ certutil -urlcache -f -split https://cnb.cool/bin456789/reinstall/-/git/raw/main
|
||||
```bash
|
||||
bash reinstall.sh anolis 7|8|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
opencloudos 8|9|23
|
||||
centos 9|10
|
||||
@@ -164,7 +164,7 @@ bash reinstall.sh anolis 7|8|23
|
||||
debian 9|10|11|12|13
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.19|3.20|3.21|3.22
|
||||
openeuler 20.03|22.03|24.03|25.03
|
||||
openeuler 20.03|22.03|24.03|25.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||
kali
|
||||
arch
|
||||
|
12
reinstall.sh
12
reinstall.sh
@@ -48,7 +48,7 @@ usage_and_exit() {
|
||||
Usage: $reinstall_____ anolis 7|8|23
|
||||
opencloudos 8|9|23
|
||||
rocky 8|9|10
|
||||
oracle 8|9
|
||||
oracle 8|9|10
|
||||
almalinux 8|9|10
|
||||
centos 9|10
|
||||
fedora 41|42
|
||||
@@ -56,7 +56,7 @@ Usage: $reinstall_____ anolis 7|8|23
|
||||
debian 9|10|11|12|13
|
||||
opensuse 15.6|tumbleweed
|
||||
alpine 3.19|3.20|3.21|3.22
|
||||
openeuler 20.03|22.03|24.03|25.03
|
||||
openeuler 20.03|22.03|24.03|25.09
|
||||
ubuntu 16.04|18.04|20.04|22.04|24.04|25.04 [--minimal]
|
||||
kali
|
||||
arch
|
||||
@@ -1629,7 +1629,9 @@ Continue with DD?
|
||||
fi
|
||||
|
||||
elarch=$basearch
|
||||
if [ "$distro" = almalinux ] && [ "$basearch" = x86_64 ] && ! is_cpu_supports_x86_64_v3; then
|
||||
if [ "$basearch" = x86_64 ] &&
|
||||
[ "$distro" = almalinux ] && [ "$releasever" -ge 10 ] &&
|
||||
! is_cpu_supports_x86_64_v3; then
|
||||
elarch=x86_64_v2
|
||||
fi
|
||||
|
||||
@@ -1864,13 +1866,13 @@ verify_os_name() {
|
||||
'opencloudos 8|9|23' \
|
||||
'almalinux 8|9|10' \
|
||||
'rocky 8|9|10' \
|
||||
'oracle 8|9' \
|
||||
'oracle 8|9|10' \
|
||||
'fedora 41|42' \
|
||||
'nixos 25.05' \
|
||||
'debian 9|10|11|12|13' \
|
||||
'opensuse 15.6|16.0|tumbleweed' \
|
||||
'alpine 3.19|3.20|3.21|3.22' \
|
||||
'openeuler 20.03|22.03|24.03|25.03' \
|
||||
'openeuler 20.03|22.03|24.03|25.09' \
|
||||
'ubuntu 16.04|18.04|20.04|22.04|24.04|25.04' \
|
||||
'redhat' \
|
||||
'kali' \
|
||||
|
135
trans.sh
135
trans.sh
@@ -442,7 +442,7 @@ EOF
|
||||
}
|
||||
|
||||
umount_all() {
|
||||
dirs="/mnt /os /iso /wim /installer /nbd /nbd-boot /nbd-efi /root /nix"
|
||||
dirs="/mnt /os /iso /wim /installer /nbd /nbd-boot /nbd-efi /nbd-test /root /nix"
|
||||
regex=$(echo "$dirs" | sed 's, ,|,g')
|
||||
if mounts=$(mount | grep -Ew "on $regex" | awk '{print $3}' | tac); then
|
||||
for mount in $mounts; do
|
||||
@@ -4447,12 +4447,36 @@ install_qcow_by_copy() {
|
||||
# 安装引导
|
||||
if is_efi; then
|
||||
# 只有centos 和 oracle x86_64 镜像没有efi,其他系统镜像已经从efi分区复制了文件
|
||||
if [ -z "$efi_part" ]; then
|
||||
remove_grub_conflict_files
|
||||
# openeuler 自带 grub2-efi-ia32,此时安装 grub2-efi 提示已经安装了 grub2-efi-ia32,不会继续安装 grub2-efi-x64
|
||||
|
||||
# 假设极端情况,qcow2 制作时,安装 grub2-efi-x64 时没有挂载 efi 分区,那么 efi 文件会在系统分区下
|
||||
# 但我们复制系统分区时挂载了 /boot/efi,因此 efi 文件会正确地复制到 efi 分区
|
||||
# 因此无需判断 qcow2 的 efi 是否是独立分区
|
||||
|
||||
# rhel 镜像没有源,直接 yum install 安装可能会报错
|
||||
# 因此如果已经安装了要用的包就不再运行 yum install
|
||||
need_install=false
|
||||
need_remove_grub_conflict_files=false
|
||||
|
||||
[ "$(uname -m)" = x86_64 ] && arch=x64 || arch=aa64
|
||||
if ! chroot $os_dir rpm -qi grub2-efi-$arch; then
|
||||
need_install=true
|
||||
need_remove_grub_conflict_files=true
|
||||
elif ! chroot $os_dir rpm -qi shim-$arch || ! chroot $os_dir rpm -qi efibootmgr; then
|
||||
need_install=true
|
||||
fi
|
||||
|
||||
if $need_install; then
|
||||
if $need_remove_grub_conflict_files; then
|
||||
remove_grub_conflict_files
|
||||
fi
|
||||
chroot_dnf install efibootmgr grub2-efi-$arch shim-$arch
|
||||
fi
|
||||
# openeuler arm 25.09 云镜像里面的 grubaa64.efi 是用于 mbr 分区表,$root 是 hd0,msdos1
|
||||
# 因此要重新下载 $root 是 hd0,gpt1 的 grubaa64.efi
|
||||
if $need_reinstall_grub_efi; then
|
||||
chroot_dnf reinstall grub2-efi-$arch
|
||||
fi
|
||||
else
|
||||
# bios
|
||||
remove_grub_conflict_files
|
||||
@@ -4799,25 +4823,76 @@ EOF
|
||||
lvchange -ay "$vg"
|
||||
fi
|
||||
|
||||
# TODO: 系统分区应该是最后一个分区
|
||||
# 选择最大分区
|
||||
os_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE | grep -E 'ext4|xfs' | tail -1 | awk '{print $1}')
|
||||
efi_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,PARTTYPE | grep -i "$EFI_UUID" | awk '{print $1}')
|
||||
# 排除前两个,再选择最大分区
|
||||
# almalinux9 boot 分区的类型不是规定的 uuid
|
||||
# openeuler boot 分区是 fat 格式
|
||||
boot_part=$(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE | grep -E 'ext4|xfs|fat' | awk '{print $1}' |
|
||||
grep -vx "$os_part" | grep -vx "$efi_part" | tail -1 | awk '{print $1}')
|
||||
mount_nouuid() {
|
||||
part_fstype=
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
/dev/*)
|
||||
part_fstype=$(lsblk -no FSTYPE "$arg")
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if $is_lvm_image; then
|
||||
os_part="mapper/$os_part"
|
||||
case "$part_fstype" in
|
||||
xfs) mount -o nouuid "$@" ;;
|
||||
*) mount "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 可以直接选择最后一个分区为系统分区?
|
||||
# almalinux9 boot 分区的类型不是规定的 uuid
|
||||
# openeuler boot 分区是 vfat 格式
|
||||
# openeuler arm 25.09 是 mbr 分区表, efi boot 是同一个分区,vfat 格式
|
||||
|
||||
info "qcow2 Partitions check"
|
||||
|
||||
# 检测分区表类型
|
||||
partition_table_format=$(get_partition_table_format /dev/nbd0)
|
||||
need_reinstall_grub_efi=false
|
||||
if is_efi && [ "$partition_table_format" = "msdos" ]; then
|
||||
need_reinstall_grub_efi=true
|
||||
fi
|
||||
|
||||
# 通过检测文件判断是什么分区
|
||||
os_part='' boot_part='' efi_part=''
|
||||
mkdir -p /nbd-test
|
||||
for part in $(lsblk /dev/nbd0p* --sort SIZE -no NAME,FSTYPE |
|
||||
grep -E ' (ext4|xfs|fat|vfat)$' | awk '{print $1}' | tac); do
|
||||
mapper_part=$part
|
||||
if $is_lvm_image && [ -e /dev/mapper/$part ]; then
|
||||
mapper_part=mapper/$part
|
||||
fi
|
||||
|
||||
if mount_nouuid -o ro /dev/$mapper_part /nbd-test; then
|
||||
if { ls /nbd-test/etc/os-release || ls /nbd-test/*/etc/os-release; } 2>/dev/null; then
|
||||
os_part=$mapper_part
|
||||
fi
|
||||
# shellcheck disable=SC2010
|
||||
# 当 boot 作为独立分区时,vmlinuz 等文件在根目录
|
||||
# 当 boot 不是独立分区时,vmlinuz 等文件在 /boot 目录
|
||||
if ls /nbd-test/ /nbd-test/boot/ 2>/dev/null | grep -Ei '^(vmlinuz|initrd|initramfs)'; then
|
||||
boot_part=$mapper_part
|
||||
fi
|
||||
# mbr + efi 引导 ,分区表没有 esp guid
|
||||
# 因此需要用 efi 文件判断是否 efi 分区
|
||||
# efi 文件可能在 efi 目录的子目录,子目录层数不定
|
||||
if find /nbd-test/ -type f -ipath '/nbd-test/EFI/*.efi' 2>/dev/null | grep .; then
|
||||
efi_part=$mapper_part
|
||||
fi
|
||||
umount /nbd-test
|
||||
fi
|
||||
done
|
||||
|
||||
info "qcow2 Partitions"
|
||||
lsblk -f /dev/nbd0 -o +PARTTYPE
|
||||
# 显示 OS/EFI/Boot 文件在哪个分区
|
||||
echo "---"
|
||||
echo "Table: $partition_table_format"
|
||||
echo "Part OS: $os_part"
|
||||
echo "Part EFI: $efi_part"
|
||||
echo "Part Boot: $boot_part"
|
||||
echo "---"
|
||||
|
||||
# 分区寻找方式
|
||||
# 系统/分区 cmdline:root fstab:efi
|
||||
@@ -4825,25 +4900,16 @@ EOF
|
||||
# ubuntu PARTUUID LABEL=UEFI
|
||||
# 其他el/ol UUID UUID
|
||||
|
||||
# read -r os_part_uuid os_part_label < <(lsblk /dev/$os_part -no UUID,LABEL)
|
||||
os_part_uuid=$(lsblk /dev/$os_part -no UUID)
|
||||
os_part_label=$(lsblk /dev/$os_part -no LABEL)
|
||||
os_part_fstype=$(lsblk /dev/$os_part -no FSTYPE)
|
||||
IFS=, read -r os_part_uuid os_part_label os_part_fstype \
|
||||
< <(lsblk /dev/$os_part -rno UUID,LABEL,FSTYPE | tr ' ' ,)
|
||||
|
||||
if [ -n "$efi_part" ]; then
|
||||
efi_part_uuid=$(lsblk /dev/$efi_part -no UUID)
|
||||
efi_part_label=$(lsblk /dev/$efi_part -no LABEL)
|
||||
IFS=, read -r efi_part_uuid efi_part_label \
|
||||
< <(lsblk /dev/$efi_part -rno UUID,LABEL | tr ' ' ,)
|
||||
fi
|
||||
|
||||
mkdir -p /nbd /nbd-boot /nbd-efi
|
||||
|
||||
mount_nouuid() {
|
||||
case "$os_part_fstype" in
|
||||
ext4) mount "$@" ;;
|
||||
xfs) mount -o nouuid "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 使用目标系统的格式化程序
|
||||
# centos8 如果用alpine格式化xfs,grub2-mkconfig和grub2里面都无法识别xfs分区
|
||||
mount_nouuid /dev/$os_part /nbd/
|
||||
@@ -4879,16 +4945,17 @@ EOF
|
||||
cp -a /nbd/* /os/
|
||||
umount /nbd/
|
||||
|
||||
# 复制boot分区,如果有
|
||||
if [ -n "$boot_part" ]; then
|
||||
# 复制独立的boot分区,如果有
|
||||
if [ -n "$boot_part" ] && ! [ "$boot_part" = "$os_part" ]; then
|
||||
echo Copying boot partition...
|
||||
mount_nouuid -o ro /dev/$boot_part /nbd-boot/
|
||||
cp -a /nbd-boot/* /os/boot/
|
||||
umount /nbd-boot/
|
||||
fi
|
||||
|
||||
# 复制efi分区,如果有
|
||||
if [ -n "$efi_part" ]; then
|
||||
# 复制独立的efi分区,如果有
|
||||
# 如果 efi 和 boot 是同一个分区,则复制 boot 分区时已经复制了 efi 分区的文件
|
||||
if [ -n "$efi_part" ] && ! [ "$efi_part" = "$os_part" ] && ! [ "$efi_part" = "$boot_part" ]; then
|
||||
echo Copying efi partition...
|
||||
mount -o ro /dev/$efi_part /nbd-efi/
|
||||
cp -a /nbd-efi/* /os/boot/efi/
|
||||
@@ -4912,11 +4979,11 @@ EOF
|
||||
umount /os/
|
||||
umount /installer/
|
||||
|
||||
# 如果镜像有efi分区,复制其uuid
|
||||
# 如果镜像有独立的efi分区(包括efi+boot在同一个分区),复制其uuid
|
||||
# 如果有相同uuid的fat分区,则无法挂载
|
||||
# 所以要先复制efi分区,断开nbd再复制uuid
|
||||
# 复制uuid前要取消挂载硬盘 efi 分区
|
||||
if is_efi && [ -n "$efi_part_uuid" ]; then
|
||||
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
|
||||
@@ -6475,7 +6542,7 @@ EOF
|
||||
done
|
||||
|
||||
if ! $is_gen11 && [ "$build_ver" -ge 19041 ]; then
|
||||
url=https://downloadmirror.intel.com/849939/SetupRST.exe # RST v20
|
||||
url=https://downloadmirror.intel.com/865363/SetupRST.exe # RST v20
|
||||
elif [ "$build_ver" -ge 15063 ]; then
|
||||
url=https://downloadmirror.intel.com/849934/SetupRST.exe # RST v19
|
||||
else
|
||||
|
Reference in New Issue
Block a user