From 94ad62429106236dc9a4647ed31e0e56295ec534 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 15 Apr 2023 04:02:07 +0200 Subject: [PATCH] Check diskspace --- install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 0f0101a..cca2e77 100644 --- a/install.sh +++ b/install.sh @@ -102,9 +102,16 @@ echo "Install: Creating partition table..." SYSTEM="$TMP/sys.img" SYSTEM_SIZE="4954537983" +# Check free diskspace +SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1) + +if (( SYSTEM_SIZE > SPACE )); then + echo "ERROR: Not enough free space to create virtual system disk." && exit 87 +fi + if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then rm -f "${SYSTEM}" - echo "ERROR: Not enough free space to create virtual disk." && exit 88 + echo "ERROR: Could not allocate file for virtual system disk." && exit 88 fi PART="$TMP/partition.fdisk"