windows: 按1.1倍iso大小得到installer分区,如无法获取iso大小就用7g

This commit is contained in:
bin456789 2023-09-28 23:51:30 +08:00
parent 13db8bf070
commit b34af7a164
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -503,6 +503,17 @@ create_part() {
# xda*1 星号用于 nvme0n1p1 的字母 p
# shellcheck disable=SC2154
if [ "$distro" = windows ]; then
if ! wget --spider -S $iso 2>/tmp/headers.log; then
error_and_exit "Can't access Windows iso."
fi
# 按1.1倍iso容量计算分区大小
part_size=$(grep 'Content-Length:' /tmp/headers.log | awk '{print int($2*1.1/1024/1024)}')
if [ -z "$part_size" ]; then
# 默认值最大的iso 23h2 需要7g
part_size=$((7 * 1024))
fi
apk add ntfs-3g-progs virt-what wimlib rsync dos2unix
# 虽然ntfs3不需要fuse但wimmount需要所以还是要保留
modprobe fuse ntfs3
@ -513,8 +524,8 @@ create_part() {
mklabel gpt \
mkpart '" "' fat32 1MiB 1025MiB \
mkpart '" "' fat32 1025MiB 1041MiB \
mkpart '" "' ext4 1041MiB -6GiB \
mkpart '" "' ntfs -6GiB 100% \
mkpart '" "' ext4 1041MiB -${part_size}MiB \
mkpart '" "' ntfs -${part_size}MiB 100% \
set 1 boot on \
set 2 msftres on \
set 3 msftdata on
@ -528,8 +539,8 @@ create_part() {
# bios
parted /dev/$xda -s -- \
mklabel msdos \
mkpart primary ntfs 1MiB -6GiB \
mkpart primary ntfs -6GiB 100% \
mkpart primary ntfs 1MiB -${part_size}GiB \
mkpart primary ntfs -${part_size}GiB 100% \
set 1 boot on
update_part /dev/$xda