Add the ability to pass a disk size to the create_vm script

Defaults to 10GB
This commit is contained in:
Greg 2021-01-22 13:49:23 +01:00
parent d1ab4c24ea
commit ab422155e4
1 changed files with 2 additions and 4 deletions

View File

@ -5,13 +5,14 @@ if [[ $# -lt 3 ]] ; then
cat <<-EOF
USAGE (RAM in megabytes)
create_vm VMNAME RAM CPUS
create_vm VMNAME RAM CPUS DISKSIZE
EOF
exit 1
fi
VMNAME=$1
RAM=$2
CPUS=$3
DISKSIZE=${4:-10} # 10GB default
# Directory where image files will be stored
IMAGE_DIR=/var/lib/libvirt/images
@ -20,9 +21,6 @@ IMAGE_PATH=$IMAGE_DIR/$IMAGE_FILE
CIDATA_PATH=${IMAGE_DIR}/cidata-${VMNAME}.iso
BASE_FILE=${IMAGE_DIR}/base/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.qcow2
# Disk size assigned to the VM
DISKSIZE=10 # Unit: GB
# Create the VM image if it does not already exist
if [ ! -f "$IMAGE_PATH" ]; then
echo "info: image file $IMAGE_PATH not found. creating new image"