mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 21:40:01 +08:00
Check diskspace
This commit is contained in:
parent
bab6554cbd
commit
6970159c8c
8
disk.sh
8
disk.sh
@ -14,10 +14,16 @@ DATA="$IMG/data$DISK_SIZE.img"
|
|||||||
|
|
||||||
if [ ! -f "$DATA" ]; then
|
if [ ! -f "$DATA" ]; then
|
||||||
|
|
||||||
|
# Check free diskspace
|
||||||
|
SPACE=$(df --output=avail -B 1 "$IMG" | tail -n 1)
|
||||||
|
if (( NEW_SIZE > SPACE )); then
|
||||||
|
echo "ERROR: Not enough free space to create virtual disk." && exit 87
|
||||||
|
fi
|
||||||
|
|
||||||
# Create an empty file
|
# Create an empty file
|
||||||
if ! fallocate -l "${NEW_SIZE}" "${DATA}"; then
|
if ! fallocate -l "${NEW_SIZE}" "${DATA}"; then
|
||||||
rm -f "${DATA}"
|
rm -f "${DATA}"
|
||||||
echo "ERROR: Not enough free space to create virtual disk." && exit 88
|
echo "ERROR: Could not allocate file for virtual disk." && exit 88
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if file exists
|
# Check if file exists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user