Setting up Cloud Init Ubuntu Image on Proxmox

Derek ArmstrongDerek Armstrong
2 min read

This is a guide on how to configure a ubuntu cloud init image on Proxmox

Imagine being able to spin up a fully configured Ubuntu virtual machine (VM) in the blink of an eye. Sounds like magic, right? Well, it’s not! It’s all about setting up a Ubuntu Cloud Init image on a Proxmox host. This nifty trick is a game-changer for engineers, making the once tedious task of manual configuration feel like a walk in the park. It’s like having your own personal assistant, automating tasks such as package updates and installations. And the best part? It’s not rocket science! In fact, it’s so straightforward that you’ll wonder why you haven’t been doing this all along. So, are you ready to make your life a whole lot easier? Let's get to it!

Instructions

Choose your Ubuntu Cloud Image

Download Ubuntu (replace with the url of the one you chose from above)

wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img

Create a new virtual machine

qm create 8000 --memory 2048 --core 2 --name ubuntu-cloud --net0 virtio,bridge=vmbr0

Import the downloaded Ubuntu disk to local-lvm storage

qm importdisk 8000 focal-server-cloudimg-amd64.img local-lvm

Attach the new disk to the vm as a scsi drive on the scsi controller

qm set 8000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-8000-disk-0

Add cloud init drive

qm set 8000 --ide2 local-lvm:cloudinit

Make the cloud init drive bootable and restrict BIOS to boot from disk only

qm set 8000 --boot c --bootdisk scsi0

Add serial console

qm set 8000 --serial0 socket --vga serial0

!! DO NOT START YOUR VM !!

Now, configure hardware and cloud init, then create a template and clone. If you want to expand your hard drive you can on this base image before creating a template or after you clone a new machine. I prefer to expand the hard drive after I clone a new machine based on need.

Create template.

qm template 8000

Clone template.

qm clone 8000 135 --name yoshi

Troubleshooting

If you need to reset your machine-id

sudo rm -f /etc/machine-id
sudo rm -f /var/lib/dbus/machine-id

Then shut it down and do not boot it up. A new id will be generated the next time it boots. If it does not you can run:

sudo systemd-machine-id-setup
0
Subscribe to my newsletter

Read articles from Derek Armstrong directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Derek Armstrong
Derek Armstrong

I share my thoughts on software development and systems engineering, along with practical soft skills and friendly advice. My goal is to inspire others, spark ideas, and discover new passions.