4、制作虚拟机模板
制作虚拟机模板 创建脚本文件 touch create_vm_tpl.sh vim create_vm_tpl.sh 粘贴如下内容 #!/usr/bin/env bash export VM_ID=8888 export IMAGE=debian-11-genericcloud-amd64.qcow2 export CPU=2 export MEMORY=4096 qm create ${VM_ID} --cores ${CPU} --memory ${MEMORY} --net0 virtio,bridge=vmbr0 qm importdisk ${VM_ID} ${IMAGE} local-lvm qm set ${VM_ID} --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-${VM_ID}-disk-0 qm set ${VM_ID} --ide2 local-lvm:cloudinit qm set ${VM_ID} --boot c --bootdisk scsi0 qm set ${VM_ID} --serial0 socket --vga serial0 qm set ${VM_ID} --agent enabled=1 qm set ${VM_ID} --sshkey ~/.ssh/id_rsa.pub qm set ${VM_ID} --cipassword 123456 --ciuser root qm template ${VM_ID}