Using cloud-init with Proxmox
Proxmox VE is a complete open-source platform for enterprise virtualization. With the built-in web interface you can easily manage VMs and containers, software-defined storage and networking, high-availability clustering, and multiple out-of-the-box tools on a single solution. 1
I have been using Proxmox as the virtualization solution for managing my servers. Proxmox provide a convenient web interface, which allow convenient access to powerful features like KVM live migration.
Cloud-init is the industry standard multi-distribution method for cross-platform cloud instance initialisation. It is supported across all major public cloud providers, provisioning systems for private cloud infrastructure, and bare-metal installations. 2
Using cloud-init, it is possible to create users, configure networking, set SSH key, etc. As the number of virtual machine grows, it becomes more and more annoying to configure each virtual machine manually. Cloud-init provides a solution to the problem, by providing a standard solution for initializing VM instances. Proxmox supports cloud-init, so in this article I will discuss how it can be used.
First of all, prepare an instance with the desired operating system normally. It is recommended to start with a small disk size like 8 GB, since it can be expanded later easily, and transferring the disk when performing live migration requires transferring the whole disk, regardless of how much disk space is actually used.
After that, run the following command:
cloud-init clean --logs --machine-id
pvdisplay
to find the physical volume./dev/sda3
, run growpart /dev/sda 3
lvdisplay
to see the logical volume name./dev/ubuntu-vg/ubuntu-lv
, run lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
.resize2fs /dev/ubuntu-vg/ubuntu-lv
.df -h
to check the volume has been successfully expanded.