From 13bd4c60ea35951f938a048c39959417f5eeca0b Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 06:54:40 +0200 Subject: [PATCH 1/5] Always allocate --- run/disk.sh | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/run/disk.sh b/run/disk.sh index c296dbb..9db98e8 100644 --- a/run/disk.sh +++ b/run/disk.sh @@ -45,19 +45,17 @@ if [ -f "${DATA}" ]; then echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATION=N." && exit 84 fi + if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then + echo "ERROR: Could not allocate a file for the virtual disk." && exit 85 + fi + if [ "$ALLOCATE" = "Z" ]; then GB=$(( (REQ + 1073741823)/1073741824 )) - echo "INFO: Writing ${GB} GB of random data, please wait.." + echo "INFO: Preallocating ${GB} GB with random data, please wait.." dd if=/dev/urandom of="${DATA}" seek="${OLD_SIZE}" count="${REQ}" bs=1M iflag=count_bytes oflag=seek_bytes status=none - else - - if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then - echo "ERROR: Could not allocate a file for the virtual disk." && exit 85 - fi - fi fi fi @@ -90,19 +88,16 @@ if [ ! -f "${DATA}" ]; then echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATION=N." && exit 86 fi + if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then + rm -f "${DATA}" + echo "ERROR: Could not allocate a file for the virtual disk." && exit 87 + fi + if [ "$ALLOCATE" = "Z" ]; then - echo "INFO: Writing ${DISK_SIZE} of random data, please wait.." - + echo "INFO: Preallocating ${DISK_SIZE} with random data, please wait.." dd if=/dev/urandom of="${DATA}" count="${DATA_SIZE}" bs=1M iflag=count_bytes status=none - else - - if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then - rm -f "${DATA}" - echo "ERROR: Could not allocate a file for the virtual disk." && exit 87 - fi - fi fi From c3291e6eaaf032dd848e5f86f07a2d8c901a8a0f Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 06:59:52 +0200 Subject: [PATCH 2/5] Always allocate --- run/install.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run/install.sh b/run/install.sh index 973d3a3..f4baa05 100644 --- a/run/install.sh +++ b/run/install.sh @@ -103,7 +103,7 @@ BOOT=$(find $TMP -name "*.bin.zip") BOOT=$(echo "$BOOT" | head -c -5) unzip -q -o "$BOOT".zip -d $TMP -echo "Install: Creating partition table..." +echo "Install: Allocating diskspace..." SYSTEM="$TMP/sys.img" SYSTEM_SIZE=4954537983 @@ -115,7 +115,11 @@ if (( SYSTEM_SIZE > SPACE )); then echo "ERROR: Not enough free space to create a 4 GB system disk." && exit 87 fi -echo "Install: Allocating diskspace..." +if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then + rm -f "${SYSTEM}" + echo "ERROR: Could not allocate a file for the system disk." && exit 88 +fi + dd if=/dev/urandom of="${SYSTEM}" count="${SYSTEM_SIZE}" bs=1M iflag=count_bytes status=none # Check if file exists @@ -131,6 +135,8 @@ if [[ SIZE -ne SYSTEM_SIZE ]]; then echo "ERROR: System disk has the wrong size: ${SIZE}" && exit 90 fi +echo "Install: Creating partition table..." + PART="$TMP/partition.fdisk" { echo "label: dos" From 31eea8b2d9a2a6c61aa53ed8ca5d32d532fa4815 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 07:05:20 +0200 Subject: [PATCH 3/5] Always allocate --- run/install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/run/install.sh b/run/install.sh index f4baa05..658d9d1 100644 --- a/run/install.sh +++ b/run/install.sh @@ -120,7 +120,12 @@ if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then echo "ERROR: Could not allocate a file for the system disk." && exit 88 fi -dd if=/dev/urandom of="${SYSTEM}" count="${SYSTEM_SIZE}" bs=1M iflag=count_bytes status=none + if [ "$ALLOCATE" = "Z" ]; then + + echo "Install: Preallocating 4 GB of diskspace..." + dd if=/dev/urandom of="${SYSTEM}" count="${SYSTEM_SIZE}" bs=1M iflag=count_bytes status=none + +fi # Check if file exists if [ ! -f "${SYSTEM}" ]; then From 3a51f186dd73c774ea63051b7e2aff0ef2cbe480 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 07:07:49 +0200 Subject: [PATCH 4/5] Always allocate --- run/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/install.sh b/run/install.sh index 658d9d1..7cb6354 100644 --- a/run/install.sh +++ b/run/install.sh @@ -103,7 +103,7 @@ BOOT=$(find $TMP -name "*.bin.zip") BOOT=$(echo "$BOOT" | head -c -5) unzip -q -o "$BOOT".zip -d $TMP -echo "Install: Allocating diskspace..." + [ "$ALLOCATE" != "Z" ] && echo "Install: Allocating diskspace..." SYSTEM="$TMP/sys.img" SYSTEM_SIZE=4954537983 From 4ae480117de75634eef4a49d3fb5ddda3c0bc043 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 07:09:08 +0200 Subject: [PATCH 5/5] Always allocate --- run/disk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/disk.sh b/run/disk.sh index 9db98e8..c0ebd1e 100644 --- a/run/disk.sh +++ b/run/disk.sh @@ -53,7 +53,7 @@ if [ -f "${DATA}" ]; then GB=$(( (REQ + 1073741823)/1073741824 )) - echo "INFO: Preallocating ${GB} GB with random data, please wait.." + echo "INFO: Preallocating ${GB} GB of diskspace, please wait..." dd if=/dev/urandom of="${DATA}" seek="${OLD_SIZE}" count="${REQ}" bs=1M iflag=count_bytes oflag=seek_bytes status=none fi @@ -95,7 +95,7 @@ if [ ! -f "${DATA}" ]; then if [ "$ALLOCATE" = "Z" ]; then - echo "INFO: Preallocating ${DISK_SIZE} with random data, please wait.." + echo "INFO: Preallocating ${DISK_SIZE} of diskspace, please wait..." dd if=/dev/urandom of="${DATA}" count="${DATA_SIZE}" bs=1M iflag=count_bytes status=none fi