Skip to content

Commit

Permalink
windows: 修复 mbr + 大于 2t 硬盘无法安装 windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bin456789 committed Jan 6, 2025
1 parent 4ed62d8 commit 13f9eda
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions trans.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,7 @@ create_part() {
# 1. vista/2008 不能删除 boot.wim
# 2. 下载镜像前不知道是 vista/2008,因为 --image-name 可以随便输入
# 因此还是要额外添加 200m
# 注意这里单位要用 MiB,因为后面的 border 要以 MiB 计算
part_size="$((size_bytes / 1024 / 1024 + 200))MiB"

apk add ntfs-3g-progs
Expand All @@ -1952,11 +1953,17 @@ create_part() {
mkfs.ntfs -f -F -L installer /dev/$xda*4 #4 installer
else
# bios + mbr 启动盘最大可用 2t
is_xda_gt_2t && max_usable_size=2TiB || max_usable_size=100%
if is_xda_gt_2t; then
border=$((2 * 1024 * 1024 - ${part_size%MiB}))MiB
max_usable_size=2TiB
else
border=${part_size}
max_usable_size=100%
fi
parted /dev/$xda -s -- \
mklabel msdos \
mkpart primary ntfs 1MiB -${part_size} \
mkpart primary ntfs -${part_size} ${max_usable_size} \
mkpart primary ntfs 1MiB -${border} \
mkpart primary ntfs -${border} ${max_usable_size} \
set 1 boot on
update_part

Expand Down

0 comments on commit 13f9eda

Please sign in to comment.