QEMU / VirtManager in combination with btrfs and Timeshift

Hi!

I recently switched to Fedora. (Fedora 36 GNOME). I manually partitioned my ssd: btrfs with @/ and @/home.
To backup my system I use Timeshift. Only @/ is backuped.

Now I installed QEMU and VirtManager and saw, that all the files are on @/. (Formerly I used Virtualbox and there was a folder in $HOME for that…)

I moved the qcow2-images in my $HOME folder. But the other things are still in @/.

The snapshots I do with VirtManager are stored in this qcow2-files, so the snapshots itself are in my $HOME-folder, is that right?

I’m afraid, that a rollback with timeshift could make problems to the configuration of the virtual machines or the snapshots (I saw xml-snapshot-files in a subfolder of /var/lib/libvirt. That is necessary to know which snapshots are done in the qcow2-image, am I right?)

What should I do further, to avoid problems with a timeshift-rollback?

Thank you very much in advance!

IMO, the easiest solution is to create a subvolume where the VMs are stored by default. That will exclude that location from your snapshots since it will be in a separate subvol.

1 Like

I already considered that. But I already moved the qcow2 files to a separate folder in $HOME. So it wouldn’t make a difference I think.

But my question is, if there are any other files, where changes could break the VM.

If I would do a rollback with timeshift, all data except the qcow2 files would set to a former state. And I am afraid, that there could be problems.

E.g. when I did a VM-snapshot and do a timeshift-rollback to a timeshift-snapshot from before the VM-snapshot was done, the VM-snapshot is in the qcow2 file but the VM-snapshot-xml-file in /var/lib/libvirt/qemu/snapshot/VMNAME is removed. That would be a problem, or not? Are there other files which could make problems?

Thank you in advance!

I don’t know which exact files matter for VMs. I have /var/lib/libvirt in a different subvolume so I don’t have to worry about it.

How can I do this retrospectively?

Not tested but something like:

  • Shutdown libvirt and all VMs
  • mv /var/lib/libvirt /var/lib/libvirt-old
  • btrfs subvolume create /var/lib/libvirt
  • mv /var/lib/libvirt-old/* /var/lib/libvirt/.
  • rmdir /var/lib/libvirt-old

Thank you very much. Your commands have worked!

After executing them, I have run sudo btrfs subvolume list / and the result was:

ID 256 gen 5964 top level 5 path @home
ID 257 gen 5964 top level 5 path @
ID 258 gen 5935 top level 257 path var/lib/machines
ID 263 gen 5957 top level 257 path var/lib/libvirt
ID 264 gen 5940 top level 5 path timeshift-btrfs/snapshots/2022-08-15_12-47-40/@

It seems that var/lib/machines was already created automatically. But there are only the qcow2 images in it. Now the whole libvirt is excluded from changes by timeshift.

Timeshift does only snapshots of root, right? All other subvolumes are excluded except of home, when you set the checkbox “Include @home” (I didn’t set it…)
I wonder only because there is no other checkbox except for the inclusion of home subvolume.

1 Like

Yes. Specifically, it only takes a snapshot of the subvolume named @ and optionally @home

Ok, that’s good, thank you!

But now I have another problem: the libvirtd.service doesn’t start anymore at startup. I did a sudo systemctl enable libvirtd and sudo systemctl start libvirtd but after restart it’s again inactive (dead):

[XXX@YYY ~]$ sudo systemctl status libvirtd
[sudo] Passwort für XXX: 
○ libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
     Active: inactive (dead)
TriggeredBy: ○ libvirtd-ro.socket
             ○ libvirtd-tcp.socket
             ○ libvirtd.socket
             ○ libvirtd-admin.socket
             ○ libvirtd-tls.socket
       Docs: man:libvirtd(8)
             https://libvirt.org

The VMs doesn’t start anymore, because the default network hasn’t started.

After a sudo systemctl start libvirtd it’s:

[XXX@YYY ~]$ sudo systemctl status libvirtd
● libvirtd.service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2022-08-15 14:22:13 CEST; 2s ago
TriggeredBy: ● libvirtd-ro.socket
             ○ libvirtd-tcp.socket
             ● libvirtd.socket
             ● libvirtd-admin.socket
             ○ libvirtd-tls.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
   Main PID: 3523 (libvirtd)
      Tasks: 19 (limit: 32768)
     Memory: 50.4M
        CPU: 757ms
     CGroup: /system.slice/libvirtd.service
             └─ 3523 /usr/sbin/libvirtd --timeout 120

And the default Network isn’t active, VMs doesn’t start.

How can I repair that? Before the creation of subvolume it worked…

There are some other interesting things:

Aug 15 14:22:12 YYY systemd[1]: Starting libvirtd.service - Virtualization daemon...
Aug 15 14:22:13 YYY systemd[1]: Started libvirtd.service - Virtualization daemon.
Aug 15 14:22:13 YYY libvirtd[3523]: libvirt version: 8.1.0, package: 2.fc36 (Fedora Project, 2022-03-13-01:12:58, )
Aug 15 14:22:13 YYY libvirtd[3523]: hostname: YYY
Aug 15 14:22:13 YYY libvirtd[3523]: Interner Fehler: Untergeordneter Prozess (VIR_BRIDGE_NAME=virbr0 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper) unerwartet Ende Status 3:
                                           dnsmasq: cannot read /var/lib/libvirt/dnsmasq/default.conf: Permission denied

Maybe SELinux?

Try:

sudo restorecon -R /var/lib/libvirt
1 Like

Are you as an user in the group libvirt ?

This could cause the “Permission denied” ?!

1 Like

Thank you for the advices! I already found a post in a forum and that was the solution for me:

Just as an addition, if you really want a stress free bridge to use with libvirt:

1 Like

Thank you, but now it works and you know: Never touch a running system!

1 Like

Nothing is more constant than changes, especially on a fast growing project as Fedora Linux.

Bookmark the link, just in case :grin:

2 Likes