proxmox-management/create_vm

44 lines
811 B
Text
Raw Normal View History

2023-10-26 16:45:29 +02:00
#!/bin/sh
set -e
CPUS=1
MEMORY=512
BRIDGE=vmbr0
STORAGE=customer-disks
OS_TYPE=l26
DISK_IMAGE=/root/images/debian-12-genericcloud-amd64.qcow2
ID=$1
NAME=$2
ORGA=$3
usage() {
printf "usage: %s <id> <name> <organisation>\n" $0
}
[ $# != 3 ] && usage && exit 1
# create vm
qm create "${ID}" \
--cpu x86-64-v3 \
--cores ${CPUS} \
--memory ${MEMORY} \
--name "${NAME}" \
--net0 "bridge=${BRIDGE},model=virtio,tag=${ID}" \
--onboot 1 \
--ostype ${OS_TYPE} \
--pool "${ORGA}" \
--scsihw virtio-scsi-pci \
--sata0 media=cdrom,file=none \
--ide2 ${STORAGE}:cloudinit
# import debian cloud image
qm set ${ID} --virtio0 ${STORAGE}:0,import-from=${DISK_IMAGE}
# resize imported disk to 50GB
qm disk resize ${ID} virtio0 50G
# change boot device to debian cloud image
qm set ${ID} --boot order=virtio0