Feasibility of mounting qcow2 image as nbd block device for backup access

I have not tried this, but curious about whether this could work.

My KVM hypervisor runs on Ubuntu 22.04 LTS. I have an old Debian 10 VM that I do not use anymore but I still have a backup of the entire image. There are some files in that image I would like to copy out of that VM image file without importing & booting up the whole VM. Is it possible to mount the image & search it like a normal mounted filesystem? If so, I need to figure that out.

Then, I question the feasibility of using this method on production VMs. For example, could we run rdiff-backup or rsync on a mounted qcow2 image file to backup up the limited parts we want vs. SSH’ing into a running vm for example.

IIRC there was a qemu-nbd command that allowed you to connect the qcow2 image to a /dev/nbdX device (not sure if that still exists, it is ages ago that I last used this), if the command is still there it is surely feasible for doing backups of files from the image

1 Like

Yes, you can mount and search within a qcow2 image.
I have used method 2 a few times. It uses qemu-nbd as mentioned by @ogra
Two Methods Here

2 Likes

Great! thank you both, I will give this a try.

Well that was easy, both methods works just fine. I think I favor the libguestfs method. I learned a little more about it here
https://libguestfs.org/guestfs-faq.1.html

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.