Mount an lvm logical volume from a qcow2 file
Mounting qcow2 files to host filesystem
Converting to raw and mounting
kpartx does not work very well with qcow2 files. You can convert the qcow2 file to a raw file:
oldfile=file.qcow2 newfile=file.raw qemu-img convert "${oldfile}" "${newfile}"
You can now find the partitions and map them:
kpartx -av "${newfile}" mount /dev/loop2p2 /mnt/foo
Modifying a virtual machine to use the new image file
You can modify a virtual machine definition to use this new file:
virsh dumpxml ${domain} > domain.xml vi domain.xml # Lines “source file=/path/file.raw” and “driver name=qemu type=raw" virsh create domain.xml
Mounting lvm logical volumes from the image file
Update lvm with the currently attached disks.
pvscan; lvscan; lvdisplay
Now you can mount /dev/mapper/cl_centos7--02a_root to a mount point.
References
Weblinks
- Converting qcow2 file to raw to make it work with kpartx https://www.certdepot.net/rhel7-access-virtual-machines-console/#comment-41448
- An alternate way to mount a qcow2 file http://ask.xmodulo.com/mount-qcow2-disk-image-linux.html
Comments