Search code examples
virtualizationkvmlibvirt

Ensuring virtual machine survives Fedora clean install


I am running Win 10 in a virtual machine under Fedora 30. I now need to do a clean install of Fedora 32. It is critical that the virtual machine survives this install.

The default location of virtual machines is under /var/lib/libvirt, which will will be run over by installation. Because of this, I now created a new pool onto a logical volume that will survive fresh OS install and used virt-clone to clone the virtual machine onto this logical volume. The cloned virtual machine is running just fine.

I can see that in the logical volume where the clone is the only file is the .qcow2-file containing the cloned virtual machine. I have two questions:

  1. In order for the virtual machine to survive clean OS installation, is it sufficient that the .qcow2-file carries over? Or do I need to copy other information from some other directory?
  2. After OS install, how do I tell virt-manager about the pool that already exists and the virtual machine that is located there?

Solution

  • You also need to at least copy the guest XML configuration files, which are stored under sub-dirs of /etc/libvirt.

    If you've stored other things like snapshots, further dirs under /var/lib/libvirt may need to be preserved.

    If you save the XML files somewhere, then in the new install "virsh define $XMLFILE" will load the guest into libvirt, such that virt-manager will see it again. You can use virt-manager's storage management UI to tell it about the pool.