mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 21:40:01 +08:00
Always allocate
This commit is contained in:
commit
ec492d55e1
27
run/disk.sh
27
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
|
echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATION=N." && exit 84
|
||||||
fi
|
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
|
if [ "$ALLOCATE" = "Z" ]; then
|
||||||
|
|
||||||
GB=$(( (REQ + 1073741823)/1073741824 ))
|
GB=$(( (REQ + 1073741823)/1073741824 ))
|
||||||
echo "INFO: Writing ${GB} GB of 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
|
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
|
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
|
echo "ERROR: Specify a smaller size or disable preallocation with ALLOCATION=N." && exit 86
|
||||||
fi
|
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
|
if [ "$ALLOCATE" = "Z" ]; then
|
||||||
|
|
||||||
echo "INFO: Writing ${DISK_SIZE} of 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
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ BOOT=$(find $TMP -name "*.bin.zip")
|
|||||||
BOOT=$(echo "$BOOT" | head -c -5)
|
BOOT=$(echo "$BOOT" | head -c -5)
|
||||||
unzip -q -o "$BOOT".zip -d $TMP
|
unzip -q -o "$BOOT".zip -d $TMP
|
||||||
|
|
||||||
echo "Install: Creating partition table..."
|
[ "$ALLOCATE" != "Z" ] && echo "Install: Allocating diskspace..."
|
||||||
|
|
||||||
SYSTEM="$TMP/sys.img"
|
SYSTEM="$TMP/sys.img"
|
||||||
SYSTEM_SIZE=4954537983
|
SYSTEM_SIZE=4954537983
|
||||||
@ -115,8 +115,17 @@ if (( SYSTEM_SIZE > SPACE )); then
|
|||||||
echo "ERROR: Not enough free space to create a 4 GB system disk." && exit 87
|
echo "ERROR: Not enough free space to create a 4 GB system disk." && exit 87
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Install: Allocating diskspace..."
|
if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then
|
||||||
dd if=/dev/urandom of="${SYSTEM}" count="${SYSTEM_SIZE}" bs=1M iflag=count_bytes status=none
|
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
|
# Check if file exists
|
||||||
if [ ! -f "${SYSTEM}" ]; then
|
if [ ! -f "${SYSTEM}" ]; then
|
||||||
@ -131,6 +140,8 @@ if [[ SIZE -ne SYSTEM_SIZE ]]; then
|
|||||||
echo "ERROR: System disk has the wrong size: ${SIZE}" && exit 90
|
echo "ERROR: System disk has the wrong size: ${SIZE}" && exit 90
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Install: Creating partition table..."
|
||||||
|
|
||||||
PART="$TMP/partition.fdisk"
|
PART="$TMP/partition.fdisk"
|
||||||
|
|
||||||
{ echo "label: dos"
|
{ echo "label: dos"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user