core: 修复缩小 btrfs 分区时,少缩小1个字节
This commit is contained in:
parent
b9288dae33
commit
ae796ce333
4
trans.sh
4
trans.sh
@ -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_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_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
|
umount /mnt/btrfs
|
||||||
printf "yes" | parted /dev/nbd0 resizepart $part_num ${part_end}B ---pretend-input-tty
|
printf "yes" | parted /dev/nbd0 resizepart $part_num ${part_end}B ---pretend-input-tty
|
||||||
|
|
||||||
# 缩小 qcow2
|
# 缩小 qcow2
|
||||||
disconnect_qcow
|
disconnect_qcow
|
||||||
qemu-img resize --shrink $qcow_file $part_end
|
qemu-img resize --shrink $qcow_file $((part_end + 1))
|
||||||
|
|
||||||
# 重新连接
|
# 重新连接
|
||||||
connect_qcow
|
connect_qcow
|
||||||
|
Loading…
Reference in New Issue
Block a user