tech_documents:virtualization:mount_virtual_images

https://ryanclouser.com/2015/07/16/QEMU-KVM-Mount-Raw-Image/

QEMU-KVM Mount Raw Image
Shut down the VM using the file

Mount the image to a loop device using kpartx
kpartx -av /path/to/img/file

It should give you a list of the partitions. They will be created in the /dev/mapper directory with the names loop0p1, loop0p2, loop0p3, etc. for every partition in the image.

Mount the partition
mount /dev/mapper/loop0p1 /mnt

Make the necessary changes

Unmount
umount /mnt

Delete the loop device
kpartx -dv /dev/loop0

Start the VM back up

Install ntfs-3g if you need to mount an NTFS partition:

yum install epel-release
yum --enablerepo epel install ntfs-3g fuse 

Note: on CentOS 7 after running kpartx -av.... it automounted in /run/media/<username>/volume name...
  • tech_documents/virtualization/mount_virtual_images.txt
  • Last modified: 2020/09/28 17:52
  • by dwadmin