mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
Make allocation method configurable
This commit is contained in:
parent
eaf7a3b89c
commit
a18cdf17d4
46
run/disk.sh
46
run/disk.sh
@ -28,20 +28,27 @@ if [ -f "${DATA}" ]; then
|
|||||||
if [ "$DATA_SIZE" -gt "$OLD_SIZE" ]; then
|
if [ "$DATA_SIZE" -gt "$OLD_SIZE" ]; then
|
||||||
|
|
||||||
echo "INFO: Resizing data disk from $OLD_SIZE to $DATA_SIZE bytes.."
|
echo "INFO: Resizing data disk from $OLD_SIZE to $DATA_SIZE bytes.."
|
||||||
|
|
||||||
REQ=$((DATA_SIZE-OLD_SIZE))
|
|
||||||
|
|
||||||
# Check free diskspace
|
|
||||||
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
|
|
||||||
|
|
||||||
if (( REQ > SPACE )); then
|
|
||||||
echo "ERROR: Not enough free space to resize virtual disk." && exit 84
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
if [ "$ALLOCATE" != "Y" ]; then
|
||||||
echo "ERROR: Could not allocate file for virtual disk." && exit 85
|
|
||||||
|
truncate -s "${DATA_SIZE}" "${DATA}";
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
REQ=$((DATA_SIZE-OLD_SIZE))
|
||||||
|
|
||||||
|
# Check free diskspace
|
||||||
|
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
|
||||||
|
|
||||||
|
if (( REQ > SPACE )); then
|
||||||
|
echo "ERROR: Not enough free space to resize virtual disk." && exit 84
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
||||||
|
echo "ERROR: Could not allocate file for virtual disk." && exit 85
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$DATA_SIZE" -lt "$OLD_SIZE" ]; then
|
if [ "$DATA_SIZE" -lt "$OLD_SIZE" ]; then
|
||||||
@ -52,18 +59,10 @@ if [ -f "${DATA}" ]; then
|
|||||||
mv -f "${DATA}" "${DATA}.bak"
|
mv -f "${DATA}" "${DATA}.bak"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${DATA}" ]; then
|
if [ ! -f "${DATA}" ]; then
|
||||||
|
|
||||||
# Check free diskspace
|
|
||||||
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
|
|
||||||
|
|
||||||
if (( DATA_SIZE > SPACE )); then
|
|
||||||
echo "ERROR: Not enough free space to create virtual disk." && exit 86
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create an empty file
|
# Create an empty file
|
||||||
|
|
||||||
if [ "$ALLOCATE" != "Y" ]; then
|
if [ "$ALLOCATE" != "Y" ]; then
|
||||||
@ -72,6 +71,13 @@ if [ ! -f "${DATA}" ]; then
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
# Check free diskspace
|
||||||
|
SPACE=$(df --output=avail -B 1 "${STORAGE}" | tail -n 1)
|
||||||
|
|
||||||
|
if (( DATA_SIZE > SPACE )); then
|
||||||
|
echo "ERROR: Not enough free space to create virtual disk." && exit 86
|
||||||
|
fi
|
||||||
|
|
||||||
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
|
||||||
rm -f "${DATA}"
|
rm -f "${DATA}"
|
||||||
echo "ERROR: Could not allocate file for virtual disk." && exit 87
|
echo "ERROR: Could not allocate file for virtual disk." && exit 87
|
||||||
|
Loading…
x
Reference in New Issue
Block a user