mirror of
https://github.com/bin456789/reinstall.git
synced 2025-12-10 07:28:56 +08:00
dd: 支持 raw vhd 格式
This commit is contained in:
33
reinstall.sh
33
reinstall.sh
@ -52,8 +52,7 @@ Usage: $reinstall____ centos 9
|
||||
kali
|
||||
arch
|
||||
gentoo
|
||||
dd --img='http://xxx.com/xxx.xz'
|
||||
dd --img='http://xxx.com/xxx.gzip'
|
||||
dd --img='http://xxx.com/xxx.raw' (supports raw vhd gzip xz)
|
||||
windows --image-name='windows xxx yyy' --lang=xx-yy
|
||||
windows --image-name='windows xxx yyy' --iso='http://xxx.com/xxx.iso'
|
||||
netboot.xyz
|
||||
@ -1063,10 +1062,32 @@ setos() {
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
setos_dd() {
|
||||
test_url $img 'xz|gzip' img_type
|
||||
# 下面两种都是 raw
|
||||
# DOS/MBR boot sector
|
||||
# x86 boot sector; partition 1: ...
|
||||
test_url $img 'xz|gzip|dos/mbr|x86' img_type
|
||||
|
||||
# 修正 raw 的 img_type
|
||||
if [ "$img_type" = dos/mbr ] || [ "$img_type" = x86 ]; then
|
||||
img_type=raw
|
||||
fi
|
||||
|
||||
if is_efi; then
|
||||
install_pkg hexdump $img_type
|
||||
install_pkg hexdump
|
||||
|
||||
if ! [ "$img_type" = raw ]; then
|
||||
install_pkg $img_type
|
||||
fi
|
||||
|
||||
extract() {
|
||||
if [ "$img_type" = raw ]; then
|
||||
cat "$1"
|
||||
else
|
||||
# xz/gzip -d 文件必须有正确的扩展名,否则报扩展名错误
|
||||
# 因此用 stdin
|
||||
$img_type -dc <"$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# openwrt 镜像 efi part type 不是 esp
|
||||
# 因此改成检测 fat?
|
||||
@ -1079,7 +1100,7 @@ setos() {
|
||||
|
||||
# 仅打印前34个扇区 * 4096字节(按最大的算)
|
||||
# 每行128字节
|
||||
"$img_type" -dc <"$tmp/img-test" | hexdump -n $((34 * 4096)) -e '128/1 "%02x" "\n"' -v >$tmp/img-test-hex
|
||||
extract "$tmp/img-test" | hexdump -n $((34 * 4096)) -e '128/1 "%02x" "\n"' -v >$tmp/img-test-hex
|
||||
if grep -q '^28732ac11ff8d211ba4b00a0c93ec93b' $tmp/img-test-hex; then
|
||||
echo 'DD: Image is EFI.'
|
||||
else
|
||||
@ -1087,7 +1108,7 @@ setos() {
|
||||
warn '
|
||||
The current machine uses EFI boot, but the DD image is not an EFI image.
|
||||
Continue with DD?
|
||||
当前机器使用 EFI 引导,但 DD 镜像不是 EFI 镜像。
|
||||
当前机器使用 EFI 引导,但 DD 镜像可能不是 EFI 镜像。
|
||||
继续 DD?'
|
||||
read -r -p '[y/N]: '
|
||||
if [[ "$REPLY" = [Yy] ]]; then
|
||||
|
||||
Reference in New Issue
Block a user