I'm attaching VM qcow2 image to get access to files which inside:

modprobe nbd max_part=63
qemu-nbd -n -c /dev/nbd0 /var/lib/libvirt/images/vm-image.qcow2

scanning for volume groups vgscan:

Reading all physical volumes. This may take a while...
No volume groups found

fdisk -l /dev/nbd0 shows only one partition /dev/nbd0p1

And of course when I try to mount mount /dev/nbd0p1 /mnt I got the following:

NTFS signature is missing.
Failed to mount '/dev/nbd0p1': Invalid argument
The device '/dev/nbd0p1' doesn't seem to have a valid NTFS.

Meanwhile, if I boot onto the VM the LVM partitions are present and system looks like ok. The host OS is well, I think, because the qemu-nbd based solution to access the qcow2 images is working well for other guest images where also LVM is present (guest OSes are slightly different releases of the same Linux distributive).

Also tried qemu-img check /var/lib/libvirt/images/vm-image.qcow2:

No errors were found on the image.

So what could be the issue with accessing/activating LVM of guest OS?

  • Have you tried running losetup /dev/loop0 /var/lib/libvirt/images/vm-image.qcow2? If that succeeds, try running sudo fdisk -l again. – zymhan Apr 1 '16 at 14:41
  • 1
    Sorry, that's not working for qcow2, only for raw images – rook Apr 1 '16 at 15:47

Alternatively have a look at guestfish, guestmont or virt-copy-out (both from libguestfs.org).

| improve this answer | |
  • Yes it seems that libguestfs solves my issues, I knew this tool but postponed moving to because of complexity and configuration issues. Anyway, now I will use libguestfs cause it clearly supports LVM in VM images and got another stuff :) – rook Apr 5 '16 at 12:35

There may be a bug with the physical volume not being initialized (udev). Try this:

modprobe nbd max_part=63
qemu-nbd -n -c /dev/nbd0 /var/lib/libvirt/images/vm-image.qcow2
partprobe /dev/nbd0
vgscan --cache
vgchange -ay
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.