1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| VM_ID=901 qm create $VM_ID --memory 1024 --net0 virtio,bridge=vmbr0
qm importdisk $VM_ID /var/lib/vz/template/iso/jammy-server-cloudimg-amd64-disk-kvm.img local-lvm qm set $VM_ID --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-$VM_ID-disk-0 qm set $VM_ID --ide0 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 --ciuser root --cipassword 123456 qm set $VM_ID --nameserver 114.114.114.114
qm set $VM_ID --ipconfig0 ip=dhcp,ip6=dhcp
qm start $VM_ID
systemctl restart sshd
cat >>/etc/apt/sources.list.d/tsinghua.sources<<eof Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg eof
partprobe /dev/sda resize2fs /dev/sda1 apt update
apt install qemu-guest-agent -y apt install --reinstall qemu-guest-agent systemctl start qemu-guest-agent && systemctl enable qemu-guest-agent qm set 901 --ipconfig0 ip=192.168.3.91/24,gw=192.168.3.2 history -c && init 0 qm template $VM_ID
for id in $(seq 1 1 8) do qm clone 1000 24${id} --name demo-vm24${id} -full true -storage local-lvm qm set 24${id} --sockets 2 --cores 2 --memory 4096 qm set 24${id} --scsi1 iothread=1,local-lvm:100 qm set 24${id} --ciuser root --cipassword 123456 qm set 24${id} --ipconfig0 ip=192.168.3.24${id}/24,gw=192.168.3.2 qm set 24${id} --nameserver 114.114.114.114 qm start 24${id} done
|