Files | Manual | Links

Creating and Configuring a VM in Proxmox with Cloud-Init

Creating and Configuring a Virtual Machine (VM) in Proxmox Using Cloud-Init

1. Note

FOUR-TB is a storage, by default - Local.
qm stop 1000       # Stop the VM if it's running
qm destroy 1000    # Delete the VM
  

2. Create a New VM with ID 1000

qm create 1000 --memory 2048 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci --agent 1
  

3. Download the Cloud Image

Debian cloud.debian.org пример: *genericcloud-amd64.qcow2

Go to cloud-images.ubuntu.com and download the latest image. For example:

cd /mnt/4tb/template/iso
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
  

4. Prepare the Image

# Copy and rename the image (change the extension)
cp jammy-server-cloudimg-amd64.img jammy-server-cloudimg-amd64.qcow2

# Resize the disk (not necessary)
qemu-img resize jammy-server-cloudimg-amd64.qcow2 3G   (2-3gb is minimal for jammy)
Can change in web panel pve resize
  

5. Import and Attach the Disk

# Import the disk into storage (e.g., FOUR-TB)
qm disk import 1000 jammy-server-cloudimg-amd64.qcow2 FOUR-TB

# Attach the disk as ide0 with discard enabled
qm set 1000 --ide0 FOUR-TB:1000/vm-1000-disk-0.raw,discard=on
  

6. Add the Cloud-Init Drive

# Assign cloud-init to ide1 (ide0 is already in use)
qm set 1000 --ide1 FOUR-TB:cloudinit
  

7. Set Boot Order

# Set the VM to boot from the main disk
qm set 1000 --boot order=ide0
  

8. Create Template and Clone

# Stop the VM
qm stop 1000

# Convert to a template
qm template 1000

#if necessary, we change the disk size
qm resize 1000 ide0 +2G

# Create a full clone
qm clone 1000 1001 --full
  

Other

Many Cloud-Init images require the use of Serial Consoles. You can configure this: QM SET 1000 —serial0 Socket --vga Serial0

If the Cloud-Init disk has already been used and you no longer need it (you can delete so that you do not occupy a slot).