Unverified Commit cc304d97 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

Make preallocation configurable

parent add19cd4
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -108,16 +108,24 @@ echo "Install: Creating partition table..."
SYSTEM="$TMP/sys.img"
SYSTEM_SIZE="4954537983"

if [ "$ALLOCATE" != "Y" ]; then

  truncate -s "${SYSTEM_SIZE}" "${SYSTEM}"; 

else

  # 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
    echo "ERROR: Not enough free space to create a 4 GB system disk." && exit 87
  fi

  if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then
    rm -f "${SYSTEM}"
  echo "ERROR: Could not allocate file for virtual system disk." && exit 88
    echo "ERROR: Could not allocate a file for the system disk." && exit 88
  fi

fi

PART="$TMP/partition.fdisk"