mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
dd: 预先检查是否为 efi 镜像
This commit is contained in:
parent
784e26608f
commit
fe660063ce
44
reinstall.sh
44
reinstall.sh
@ -63,7 +63,7 @@ info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
echo_color_text '\e[33m' "Warn: $*"
|
echo_color_text '\e[33m' "Warning: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
@ -230,7 +230,7 @@ test_url_real() {
|
|||||||
error_and_exit "$@"
|
error_and_exit "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_file=$tmp/reinstall-img-test
|
tmp_file=$tmp/img-test
|
||||||
|
|
||||||
# 有的服务器不支持 range,curl会下载整个文件
|
# 有的服务器不支持 range,curl会下载整个文件
|
||||||
# 用 dd 限制下载 1M
|
# 用 dd 限制下载 1M
|
||||||
@ -1010,8 +1010,40 @@ setos() {
|
|||||||
|
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
setos_dd() {
|
setos_dd() {
|
||||||
test_url $img 'xz|gzip' ${step}_img_type
|
test_url $img 'xz|gzip' img_type
|
||||||
|
|
||||||
|
if is_efi; then
|
||||||
|
install_pkg hexdump $img_type
|
||||||
|
|
||||||
|
# od 在 coreutils 里面,好像要配合 tr 才能删除空格
|
||||||
|
# hexdump 在 util-linux / bsdmainutils 里面
|
||||||
|
# xxd 要单独安装,el 在 vim-common 里面
|
||||||
|
# xxd -l $((34 * 4096)) -ps -c 512
|
||||||
|
|
||||||
|
# 仅打印前34个扇区 * 4096字节(按最大的算)
|
||||||
|
# 每行512字节
|
||||||
|
"$img_type" -dc <"$tmp/img-test" | hexdump -n $((34 * 4096)) -e '512/1 "%02x" "\n"' -v >$tmp/img-test-raw
|
||||||
|
if grep -q '^28732ac11ff8d211ba4b00a0c93ec93b' $tmp/img-test-raw; then
|
||||||
|
echo 'DD: Image is EFI.'
|
||||||
|
else
|
||||||
|
echo 'DD: Image is not EFI.'
|
||||||
|
warn '
|
||||||
|
The current machine uses EFI boot, but the DD image is not an EFI image.
|
||||||
|
Continue with DD? [Y/N]
|
||||||
|
|
||||||
|
当前机器使用 EFI 引导,但 DD 镜像不是 EFI 镜像。
|
||||||
|
继续 DD? [Y/N]
|
||||||
|
'
|
||||||
|
read -r -n 1
|
||||||
|
if [[ "$REPLY" = [Yy] ]]; then
|
||||||
|
eval ${step}_confirmed_no_efi=1
|
||||||
|
else
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
eval "${step}_img='$img'"
|
eval "${step}_img='$img'"
|
||||||
|
eval "${step}_img_type='$img_type'"
|
||||||
}
|
}
|
||||||
|
|
||||||
setos_centos_alma_rocky_fedora() {
|
setos_centos_alma_rocky_fedora() {
|
||||||
@ -1316,6 +1348,12 @@ install_pkg() {
|
|||||||
*) pkg="util-linux" ;;
|
*) pkg="util-linux" ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
hexdump)
|
||||||
|
case "$pkg_mgr" in
|
||||||
|
apt) pkg="bsdmainutils" ;;
|
||||||
|
*) pkg="util-linux" ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
unsquashfs)
|
unsquashfs)
|
||||||
case "$pkg_mgr" in
|
case "$pkg_mgr" in
|
||||||
zypper) pkg="squashfs" ;;
|
zypper) pkg="squashfs" ;;
|
||||||
|
11
trans.sh
11
trans.sh
@ -633,7 +633,13 @@ add_fallback_efi_to_nvram() {
|
|||||||
efibootmgr --bootorder "$new_order"
|
efibootmgr --bootorder "$new_order"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "
|
# shellcheck disable=SC2154
|
||||||
|
if [ "$confirmed_no_efi" = 1 ]; then
|
||||||
|
echo 'Confirmed no EFI in previous step.'
|
||||||
|
else
|
||||||
|
# reinstall.sh 里确认过一遍,但是逻辑扇区大于 512 时,可能漏报?
|
||||||
|
# 这里的应该会根据逻辑扇区来判断?
|
||||||
|
echo "
|
||||||
Warning: This machine is currently using EFI boot, but the main hard drive does not have an EFI partition.
|
Warning: This machine is currently using EFI boot, but the main hard drive does not have an EFI partition.
|
||||||
If this machine supports Legacy BIOS boot (CSM), you can safely restart into the new system by running the reboot command.
|
If this machine supports Legacy BIOS boot (CSM), you can safely restart into the new system by running the reboot command.
|
||||||
If this machine does not support Legacy BIOS boot (CSM), you will not be able to enter the new system after rebooting.
|
If this machine does not support Legacy BIOS boot (CSM), you will not be able to enter the new system after rebooting.
|
||||||
@ -642,7 +648,8 @@ If this machine does not support Legacy BIOS boot (CSM), you will not be able to
|
|||||||
如果本机支持 Legacy BIOS 引导 (CSM),你可以运行 reboot 命令安全地重启到新系统。
|
如果本机支持 Legacy BIOS 引导 (CSM),你可以运行 reboot 命令安全地重启到新系统。
|
||||||
如果本机不支持 Legacy BIOS 引导 (CSM),重启后将无法进入新系统。
|
如果本机不支持 Legacy BIOS 引导 (CSM),重启后将无法进入新系统。
|
||||||
"
|
"
|
||||||
exit
|
exit
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user