1

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?

rook
  • 137
  • 1
  • 1
  • 14
  • 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 01 '16 at 14:41
  • 1
    Sorry, that's not working for `qcow2`, only for `raw` images – rook Apr 01 '16 at 15:47

2 Answers2

2

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
h0tw1r3
  • 2,776
  • 19
  • 17
2

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

rook
  • 137
  • 1
  • 1
  • 14
Martian
  • 1,100
  • 8
  • 8
  • 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 05 '16 at 12:35