I had to rebuild VM recently, and I want to record what I did to get it to boot.
I downloaded Fedoare 45 boot image from here:
https://download.fedoraproject.org/pub/fedora/linux/releases/45/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-45-1.4.x86_64.qcow2
I resized it
qemu-img resize ~/Downloads/Fedora-Cloud-Base-Generic-45-1.4.x86_64.qcow2 +20G
I copied that to the target location:
sudo cp ~/Downloads/Fedora-Cloud-Base-Generic-45-1.4.x86_64.qcow2 /var/lib/libvirt/images/athena.qcow2
I have a directroy with the could-init files in it. They look like this
/home/ayoung/devel/cloud-init/user-data
#cloud-config
users:
- name: ayoung
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDGXO2uMPfAv7X4k7tLEwnpTR9j1niYo9oZ1uXTqg54jOBErqGFdWd2DHgBV5qaidYR8x3UCquS+v57JkMv/lNLXyeKA/TrwVlTn0xdHd4SUixlG6n9TcSJjiMcbo8XQTX7ec3Zvmrkd0muH2G1ZtHRl9awKJMffqxypSc8igDbKnHp/7BxWw2+SbXvI61gjCWeF3QtaAhZfkYNwofCwOBMvAfG5kuT/PYEFe2eLARo2o5QYFCQdOfUHqLVYIroYxiKfFHQHbStsl3cUwAo2eM4mTC28V0b4so/7wNDJW/vNroVOC4IRJgpacNb7+tOIpbxfQ5M1x1k44QFSCmJEmDyiKVdAb7CPW4tY0Yc3ESw0jyfOk57KRWni56EoBxRbAEWnKeK6RHo/jrPq3vlYwNtB0Vx3mcWh2k4bwtcDr2MhC4YqCY6rwLfhJaKMW/qc5CNy9d4BS97M5uaWryBRUZFgLjekrdVKQ3oFh43sybfwDdoHaSADucQfKtchUh/6cs= ayoung@ayoung-home.amperecomputing.com
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: wheel
shell: /bin/bash
/home/ayoung/.ssh/id_ed25519.pub
I also have a meta-data file in that directory, but it is empty. I created it using touch
The following command installs the VM. Note that I have the empty meta-data file included. The cloud-init process silently fails without that.
sudo virt-install --name athena --memory 16000 --vcpus 4 --os-variant fedora-unknown --disk /var/lib/libvirt/images/athena.qcow2 --cloud-init user-data=/home/ayoung/devel/cloud-init/user-data,meta-data=/home/ayoung/devel/cloud-init/meta-data --network network=default,model=virtio --graphics none --import
Once the VM boots, the IP address is listed in the cloud-init portion of the boot log.