I am trying to make a template for my Ubuntu VMs mostly by following Techno Tim's instructions here. I differ from Tim by wanting to also install qemu-guest-agent so I can get the IP of the vm without having to do it manually. I do this before importing the .img by using the command virt-customize -a focal-minimal-cloudimg-amd64.img --install qemu-guest-agent. But unfortunately this does me the favor of setting the machine-id, which I do not want in my template. Now, I could also run virt-customize -a focal-minimal-cloudimg-amd64.img --delete /etc/machine-id as well as in /var/lib/dbus/machine-id which does the trick and deletes it. But unfortunately during boot of any new VM from that, the system boots with many errors because machine-id is not there and for some reason /etc is mounted as read only. Is there any way to fix this?
I can get around this by instead of deleting with virt-customize, I can put in a firstboot script through virt-customize that deletes and regenerates a machine-id with a reboot to make it take effect, but this seems like a less than ideal way to do this. Is there a better way?