mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
Prepare image resizing
This commit is contained in:
parent
07c40ada2d
commit
0e28a1e4ee
23
disk.sh
23
disk.sh
@ -10,16 +10,35 @@ FILE="$IMG/$BASE.boot.img"
|
|||||||
FILE="$IMG/$BASE.system.img"
|
FILE="$IMG/$BASE.system.img"
|
||||||
[ ! -f "$FILE" ] && echo "ERROR: Virtual DSM system-image does not exist ($FILE)" && exit 82
|
[ ! -f "$FILE" ] && echo "ERROR: Virtual DSM system-image does not exist ($FILE)" && exit 82
|
||||||
|
|
||||||
|
DISK_SIZE=$(echo "${DISK_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
|
NEW_SIZE=$(numfmt --from=iec "${DISK_SIZE}")
|
||||||
|
|
||||||
FILE="$IMG/data$DISK_SIZE.img"
|
FILE="$IMG/data$DISK_SIZE.img"
|
||||||
|
|
||||||
if [ ! -f "$FILE" ]; then
|
if [ ! -f "$FILE" ]; then
|
||||||
truncate -s "$DISK_SIZE" "$FILE"
|
truncate -s "${NEW_SIZE}" "${FILE}"
|
||||||
mkfs.btrfs -q -L data -d single -m single "$FILE" > /dev/null
|
mkfs.btrfs -q -L data -d single -m single "${FILE}" > /dev/null
|
||||||
#qemu-img convert -f raw -O qcow2 -o extended_l2=on,cluster_size=128k,compression_type=zstd,preallocation=metadata "$TMP" "$FILE"
|
#qemu-img convert -f raw -O qcow2 -o extended_l2=on,cluster_size=128k,compression_type=zstd,preallocation=metadata "$TMP" "$FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -f "$FILE" ] && echo "ERROR: Virtual DSM data-image does not exist ($FILE)" && exit 83
|
[ ! -f "$FILE" ] && echo "ERROR: Virtual DSM data-image does not exist ($FILE)" && exit 83
|
||||||
|
|
||||||
|
#OLD_SIZE=$(stat -c%s "${FILE}")
|
||||||
|
#
|
||||||
|
#if [ "$NEW_SIZE" -ne "$OLD_SIZE" ]; then
|
||||||
|
# echo "Resizing data disk from $OLD_SIZE to $NEW_SIZE bytes"
|
||||||
|
#
|
||||||
|
# if [ "$NEW_SIZE" -gt "$OLD_SIZE" ]; then
|
||||||
|
# truncate -s "${NEW_SIZE}" "${FILE}"
|
||||||
|
# btrfs filesystem resize "${NEW_SIZE}" "${FILE}"
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# if [ "$NEW_SIZE" -lt "$OLD_SIZE" ]; then
|
||||||
|
# btrfs filesystem resize "${NEW_SIZE}" "${FILE}"
|
||||||
|
# truncate -s "${NEW_SIZE}" "${FILE}"
|
||||||
|
# fi
|
||||||
|
#fi
|
||||||
|
|
||||||
KVM_DISK_OPTS="\
|
KVM_DISK_OPTS="\
|
||||||
-device virtio-scsi-pci,id=hw-synoboot,bus=pcie.0,addr=0xa \
|
-device virtio-scsi-pci,id=hw-synoboot,bus=pcie.0,addr=0xa \
|
||||||
-drive file=${IMG}/${BASE}.boot.img,if=none,id=drive-synoboot,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on \
|
-drive file=${IMG}/${BASE}.boot.img,if=none,id=drive-synoboot,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user