Always allocate

This commit is contained in:
Kroese 2023-04-19 07:11:32 +02:00 committed by GitHub
commit ec492d55e1
2 changed files with 25 additions and 19 deletions

View File

@ -45,19 +45,17 @@ if [ -f "${DATA}" ]; then
echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATION=N." && exit 84
fi
if [ "$ALLOCATE" = "Z" ]; then
GB=$(( (REQ + 1073741823)/1073741824 ))
echo "INFO: Writing ${GB} GB of 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
if [ "$ALLOCATE" = "Z" ]; then
GB=$(( (REQ + 1073741823)/1073741824 ))
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
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 [ "$ALLOCATE" = "Z" ]; then
echo "INFO: Writing ${DISK_SIZE} of 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
if [ "$ALLOCATE" = "Z" ]; then
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
fi

View File

@ -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..."
[ "$ALLOCATE" != "Z" ] && echo "Install: Allocating diskspace..."
SYSTEM="$TMP/sys.img"
SYSTEM_SIZE=4954537983
@ -115,9 +115,18 @@ 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
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
echo "ERROR: System disk does not exist ($SYSTEM)" && exit 89
@ -131,6 +140,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"