core: 修复缩小 btrfs 分区时,少缩小1个字节

This commit is contained in:
bin456789 2024-03-01 23:26:49 +08:00
parent b9288dae33
commit ae796ce333
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -1769,13 +1769,13 @@ dd_qcow() {
# 缩小分区
part_start=$(parted /dev/nbd0 -s 'unit b print' | awk "\$1==$part_num {print \$2}" | sed 's/B//')
part_size=$(btrfs filesystem usage /mnt/btrfs -b | grep 'Device size:' | awk '{print $3}')
part_end=$((part_start + part_size))
part_end=$((part_start + part_size - 1))
umount /mnt/btrfs
printf "yes" | parted /dev/nbd0 resizepart $part_num ${part_end}B ---pretend-input-tty
# 缩小 qcow2
disconnect_qcow
qemu-img resize --shrink $qcow_file $part_end
qemu-img resize --shrink $qcow_file $((part_end + 1))
# 重新连接
connect_qcow