Can I recover a VM where the file system got corrupted?

Hi,

For whatever strange reason, the file system on one of my standalone VMs got corrupted. A quick check found that this lad was running Fedora 34.

I found the rw part of this VM in dom0 by running “lsblk” and looking for the VM name with -private on the end. Then I mounted it on dom0 and used tar to make a copy of the user data, which I sent over to a clean standalone VM (which was a clone of a VM doing a similar job).

So I am up and running again.

I wondered if I could have mounted the root of that standalone VM instead, and run efsck (or whatever) to fix the file system?

For reference, this is what I did in Dom0:

sudo mkdir /mnt/fixme

sudo mount /dev/mapper/qubes_dom0-vm--YOUR_VM_NAME--private /mnt/fixme

tar -czf /tmp/tarcopy.tgz /mnt/fixme/user

qvm-copy-to-vm Rescue_VM_name /tmp/tarcopy.tgz

Not a good approach, you effectively accessed untrusted data from dom0.

As it’s often the case, reading the documentation can likely lead you to a more appropriate solution: How to mount LVM images | Qubes OS

2 Likes

To expand on this, because it seems like the crux of the problem that’s tripping up people again and again - is that it’s not obvious what counts as “data”:

4 Likes

Next time, as soon as you realize vm doesnt boot, you might want to clone to backup and revert faulty vm/template with qubes os provided tools.

Did a small writeup at Template doesn’t boot after update (no space left on device) - #13 by Insurgo

2 Likes