mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 21:40:01 +08:00
Check free diskspace
This commit is contained in:
parent
77eb81c6fe
commit
bab6554cbd
13
disk.sh
13
disk.sh
@ -2,9 +2,9 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
BOOT="$IMG/$BASE.boot.img"
|
BOOT="$IMG/$BASE.boot.img"
|
||||||
[ ! -f "$BOOT" ] && echo "ERROR: Virtual DSM boot-image does not exist ($BOOT)" && exit 81
|
|
||||||
|
|
||||||
SYSTEM="$IMG/$BASE.system.img"
|
SYSTEM="$IMG/$BASE.system.img"
|
||||||
|
|
||||||
|
[ ! -f "$BOOT" ] && echo "ERROR: Virtual DSM boot-image does not exist ($BOOT)" && exit 81
|
||||||
[ ! -f "$SYSTEM" ] && echo "ERROR: Virtual DSM system-image does not exist ($SYSTEM)" && exit 82
|
[ ! -f "$SYSTEM" ] && echo "ERROR: Virtual DSM system-image does not exist ($SYSTEM)" && exit 82
|
||||||
|
|
||||||
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')
|
||||||
@ -13,17 +13,22 @@ NEW_SIZE=$(numfmt --from=iec "${DISK_SIZE}")
|
|||||||
DATA="$IMG/data$DISK_SIZE.img"
|
DATA="$IMG/data$DISK_SIZE.img"
|
||||||
|
|
||||||
if [ ! -f "$DATA" ]; then
|
if [ ! -f "$DATA" ]; then
|
||||||
|
|
||||||
# Create an empty file
|
# Create an empty file
|
||||||
if ! fallocate -l "${NEW_SIZE}" "${DATA}"; then
|
if ! fallocate -l "${NEW_SIZE}" "${DATA}"; then
|
||||||
rm -f "${DATA}"
|
rm -f "${DATA}"
|
||||||
echo "ERROR: Not enough free space to create virtual disk." && exit 88
|
echo "ERROR: Not enough free space to create virtual disk." && exit 88
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if [ ! -f "$DATA" ]; then
|
||||||
|
echo "ERROR: Virtual DSM data-image does not exist ($DATA)" && exit 83
|
||||||
|
fi
|
||||||
|
|
||||||
# Format as BTRFS filesystem
|
# Format as BTRFS filesystem
|
||||||
mkfs.btrfs -q -L data -d single -m dup "${DATA}" > /dev/null
|
mkfs.btrfs -q -L data -d single -m dup "${DATA}" > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -f "$DATA" ] && echo "ERROR: Virtual DSM data-image does not exist ($DATA)" && exit 83
|
|
||||||
|
|
||||||
# Resizing requires mounting a loop device which in turn requires
|
# Resizing requires mounting a loop device which in turn requires
|
||||||
# the container to be privileged, so we must disable it for now.
|
# the container to be privileged, so we must disable it for now.
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user