From 5f212b4041bd86d323ecc8611a1acc850315f039 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 02:55:06 +0200 Subject: [PATCH] Add full allocation mode (write zeroes) --- run/install.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/run/install.sh b/run/install.sh index b50a911..88ef32b 100644 --- a/run/install.sh +++ b/run/install.sh @@ -106,7 +106,7 @@ unzip -q -o "$BOOT".zip -d $TMP echo "Install: Creating partition table..." SYSTEM="$TMP/sys.img" -SYSTEM_SIZE="4954537983" +SYSTEM_SIZE=4954537983 # Check free diskspace SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1) @@ -115,9 +115,20 @@ if (( SYSTEM_SIZE > SPACE )); then 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 a file for the system disk." && exit 88 +if [ "$ALLOCATE" != "F" ]; then + + if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then + rm -f "${SYSTEM}" + echo "ERROR: Could not allocate a file for the system disk." && exit 88 + fi + +else + + MB=(( (SYSTEM_SIZE + 1048575)/1048576 )) + + dd if=/dev/zero of="${SYSTEM}" count="${MB}" bs=1M + truncate -s "${SYSTEM_SIZE}" "${SYSTEM}" + fi PART="$TMP/partition.fdisk"