Check free diskspace

This commit is contained in:
Kroese 2023-04-15 02:15:18 +02:00
parent c88072c97e
commit 77eb81c6fe
2 changed files with 9 additions and 2 deletions

View File

@ -14,7 +14,10 @@ DATA="$IMG/data$DISK_SIZE.img"
if [ ! -f "$DATA" ]; then
# Create an empty file
fallocate -l "${NEW_SIZE}" "${DATA}"
if ! fallocate -l "${NEW_SIZE}" "${DATA}"; then
rm -f "${DATA}"
echo "ERROR: Not enough free space to create virtual disk." && exit 88
fi
# Format as BTRFS filesystem
mkfs.btrfs -q -L data -d single -m dup "${DATA}" > /dev/null
fi

View File

@ -101,7 +101,11 @@ echo "Install: Creating partition table..."
SYSTEM="$TMP/sys.img"
SYSTEM_SIZE="4954537983"
fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"
if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then
rm -f "${SYSTEM}"
echo "ERROR: Not enough free space to create virtual disk." && exit 88
fi
PART="$TMP/partition.fdisk"