Disk image creation


I have created a Fedora 38 Workstation virtual machine in Gnome-Boxes that fits my needs in terms of installed / uninstalled softwares, parameters, customisations, etc, and I wish to create an image of that VM so that I can restore it easily on any physical computer.
Could you explain me how can I do this ?

Create the VM exactly as you wish.
Once that is done then (when using livvirt and VMM) simply copy the qcow2 file for the VM and it can be restored onto anther system. I am unsure of the file name created when using boxes but the process should be similar.

The related files with libvirt are located under /var/lib/libvirt/

Thanks a lot for your advice !

My goal is to speedup further installations. I just need a template virtual machine that I keep it up to date. With that VM I can create a disk image that I can use to restore a fully functional system with all customisations on any physical drive. This way installations are much faster !

For any interested people, here’s what I’ve done to make it work :

  • If it’s not already installed :
sudo dnf install qemu-kvm -y
  • Then if you created your VM in Gnome-Boxes :
cd ~/.local/share/gnome-boxes/images/
qemu-img convert yourvm.qcow2 -O raw yourdisk.img
  • Restore the image to a physical drive with Gnome-Disk application or command line :
sudo dd if=~/.local/share/gnome-boxes/images/yourdisk.img of=/dev/sdX
  • Resize root (or home) partition on the new drive with GParted to use the entire disk
  • Reboot to the newly restored drive but select the “recovery” entry in Grub boot menu
  • When a session is open, regenerate initramfs :
sudo dracut --regenerate-all --force
  • That’s all !