Storage
This commit is contained in:
Kroese 2023-04-16 16:14:43 +02:00 committed by GitHub
commit f742b42a28
3 changed files with 8 additions and 8 deletions

View file

@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
BOOT="$IMG/boot.img" BOOT="$STORAGE/boot.img"
[ ! -f "$BOOT" ] && echo "ERROR: Boot image does not exist ($BOOT)" && exit 81 [ ! -f "$BOOT" ] && echo "ERROR: Boot image does not exist ($BOOT)" && exit 81
DATA="${IMG}/data.img" DATA="${STORAGE}/data.img"
DISK_SIZE=$(echo "${DISK_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') DISK_SIZE=$(echo "${DISK_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
DATA_SIZE=$(numfmt --from=iec "${DISK_SIZE}") DATA_SIZE=$(numfmt --from=iec "${DISK_SIZE}")
@ -19,7 +19,7 @@ if [ -f "${DATA}" ]; then
REQ=$((DATA_SIZE-OLD_SIZE)) REQ=$((DATA_SIZE-OLD_SIZE))
# Check free diskspace # Check free diskspace
SPACE=$(df --output=avail -B 1 "${IMG}" | tail -n 1) SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
if (( REQ > SPACE )); then if (( REQ > SPACE )); then
echo "ERROR: Not enough free space to resize virtual disk." && exit 84 echo "ERROR: Not enough free space to resize virtual disk." && exit 84
@ -45,7 +45,7 @@ fi
if [ ! -f "${DATA}" ]; then if [ ! -f "${DATA}" ]; then
# Check free diskspace # Check free diskspace
SPACE=$(df --output=avail -B 1 "${IMG}" | tail -n 1) SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
if (( DATA_SIZE > SPACE )); then if (( DATA_SIZE > SPACE )); then
echo "ERROR: Not enough free space to create virtual disk." && exit 86 echo "ERROR: Not enough free space to create virtual disk." && exit 86

View file

@ -21,6 +21,6 @@ if ((SIZE<1000000)); then
echo "Invalid ISO file: Size is smaller than 1 MB." && exit 62 echo "Invalid ISO file: Size is smaller than 1 MB." && exit 62
fi fi
FILE="$IMG/boot.img" FILE="$STORAGE/boot.img"
mv -f "$TMP" "$FILE" mv -f "$TMP" "$FILE"

View file

@ -3,10 +3,10 @@ set -eu
echo "Starting QEMU..." echo "Starting QEMU..."
IMG="/storage" STORAGE="/storage"
[ ! -d "$IMG" ] && echo "Storage folder (${IMG}) not found!" && exit 69 [ ! -d "$STORAGE" ] && echo "Storage folder (${STORAGE}) not found!" && exit 69
if [ -f "$IMG/boot.img" ]; then if [ -f "$STORAGE/boot.img" ]; then
. /run/install.sh . /run/install.sh
fi fi