Add the ability to pass a disk size to the create_vm script
Defaults to 10GB
This commit is contained in:
parent
fd4844a012
commit
9a4420fc11
@ -5,13 +5,14 @@ if [[ $# -lt 3 ]] ; then
|
|||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
USAGE (RAM in megabytes)
|
USAGE (RAM in megabytes)
|
||||||
|
|
||||||
create_vm VMNAME RAM CPUS
|
create_vm VMNAME RAM CPUS DISKSIZE
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
VMNAME=$1
|
VMNAME=$1
|
||||||
RAM=$2
|
RAM=$2
|
||||||
CPUS=$3
|
CPUS=$3
|
||||||
|
DISKSIZE=${4:-10} # 10GB default
|
||||||
|
|
||||||
# Directory where image files will be stored
|
# Directory where image files will be stored
|
||||||
IMAGE_DIR=/var/lib/libvirt/images
|
IMAGE_DIR=/var/lib/libvirt/images
|
||||||
@ -20,9 +21,6 @@ IMAGE_PATH=$IMAGE_DIR/$IMAGE_FILE
|
|||||||
CIDATA_PATH=${IMAGE_DIR}/cidata-${VMNAME}.iso
|
CIDATA_PATH=${IMAGE_DIR}/cidata-${VMNAME}.iso
|
||||||
BASE_FILE=${IMAGE_DIR}/base/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.qcow2
|
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
|
# Create the VM image if it does not already exist
|
||||||
if [ ! -f "$IMAGE_PATH" ]; then
|
if [ ! -f "$IMAGE_PATH" ]; then
|
||||||
echo "info: image file $IMAGE_PATH not found. creating new image"
|
echo "info: image file $IMAGE_PATH not found. creating new image"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user