Post

How to create Cloud-Init Kali template in Proxmox

How to create Cloud-Init Kali template in Proxmox

How to create Cloud-Init Kali template in Proxmox

Tutorial

Prepare img file

  • You need to have installed 7z:
    1
    
    apt install -y libguestfs-tools p7zip-full
    

  1. Download file into /var/lib/vz/template/iso/ with wget:
    1
    
    wget https://cdimage.kali.org/kali-2024.4/kali-linux-2024.4-vmware-amd64.7z -o /var/lib/vz/template/iso/kali-linux-2024.4-vmware-amd64.7z && cd /var/lib/vz/template/iso/
    
  2. Extract downloaded files:
    1
    
    7z x kali-linux-2024.4-vmware-amd64.7z
    
  3. Convert image VMDK into RAW:
    1
    
    qemu-img convert -f vmdk -O raw kali-linux-2024.4-vmware-amd64.vmwarevm/kali-linux-2024.4-vmware-amd64.vmdk kali-2024.4.img
    
  4. We can customize our RAW img file thanks to libquestfs-tools:
    1. Install cloud-init:
      1
      
       virt-customize -a kali-2024.4.img --install cloud-init
      
    2. Install qemu-guest-agent & spice-vdagent:
      1
      2
      
       virt-customize -a kali-2024.4.img --install qemu-guest-agent
       virt-customize -a kali-2024.4.img --install spice-vdagent
      
    3. (Optional) Enable SSH, It’s disabled by default:
      1
      
       virt-customize -a kali-2024.4.img --run-command 'systemctl enable ssh.service'
      
    1. Enable Cloud-Init, It’s also disabled by default
      1
      
       virt-customize -a kali-2024.4.img --run-command 'systemctl enable cloud-init-main'
      
    1. Update your image: it’s gonna take a while …
      1
      
       virt-customize -a kali-2024.4.img --update
      
  5. We’ve got prepared file kali-2024.4.img

Prepare Proxmox TEMPLATE

  1. Create empty template:
    1
    
    qm create 9000 --memory 4096 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
    

vmbr0 Can be different, depends on your network devices…

  1. Import our prepared img file kali-2024.4.img to our template:
    1
    
    qm set 9000 --scsi0 local-zfs:0,import-from=/var/lib/vz/template/iso/kali-2024.4.img
    

local-zfs Can be different, depends on your Proxmox installation.

  1. Add cloud-init disk:
    1
    
    qm set 9000 --ide2 local-zfs:cloudinit
    

local-zfs Can be different, depends on your Proxmox installation.

  1. Define boot order:
    1
    
    qm set 9000 --boot c --bootdisk scsi0
    
  2. OPTIONAL: Add ability to serial socket for Console xterm.js
    1
    
    qm set 9000 --serial0 socket --vga serial0
    
  3. Convert VM into template
    1
    
    qm template 9000
    

Now you are able to clone from Template, and before start the VM you can set Cloud-Init variables…


Some additional info

  • User kali/kali will remains…
  • This article was tested on Proxmox 8.2.7
  • You can check cloud-init by cloud-init status

Sources

This post is licensed under CC BY 4.0 by the author.