Check free diskspace
This commit is contained in:
parent
d3401b820b
commit
2d4b6e8bd9
1 changed files with 8 additions and 1 deletions
9
disk.sh
9
disk.sh
|
@ -8,7 +8,14 @@ DISK_SIZE=$(echo "${DISK_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||||
DATA_SIZE=$(numfmt --from=iec "${DISK_SIZE}")
|
DATA_SIZE=$(numfmt --from=iec "${DISK_SIZE}")
|
||||||
|
|
||||||
DATA="$IMG/data${DISK_SIZE}.img"
|
DATA="$IMG/data${DISK_SIZE}.img"
|
||||||
[ ! -f "$DATA" ] && fallocate -l "${DATA_SIZE}" "${DATA}"
|
|
||||||
|
if [ ! -f "$DATA" ]; then
|
||||||
|
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
||||||
|
rm -f "${DATA}"
|
||||||
|
echo "ERROR: Not enough free space to create virtual disk." && exit 82
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
[ ! -f "$DATA" ] && echo "ERROR: Data image does not exist ($DATA)" && exit 83
|
[ ! -f "$DATA" ] && echo "ERROR: Data image does not exist ($DATA)" && exit 83
|
||||||
|
|
||||||
KVM_DISK_OPTS="\
|
KVM_DISK_OPTS="\
|
||||||
|
|
Loading…
Reference in a new issue