0

I want to mount the raw disk image (read only) from a running linux kvm virtual machine, to access the data outside the vm.

It works for accessing the files, but doesn't reflects filesystem changes:

losetup /dev/loop0 disk1.raw # image of running vm
mount -o ro /dev/loop0 /mnt/disk1ro

After a touch of the file in the vm, the file doesn't exists in the mount point. When I do unmount and mount it again it's there.

I didn't found a mount option which helped. Is any kernel cache preventing the update?

A nfs server in the vm would be a solution, but to directly work with the image would be a lot more simple and slick trick (if it worked)!

Update: ok I agree with the others, this is a bad idea

  • I doubt this could work, since the entity mapping the raw image isn't notified in any way of the changes to the file system structure. Some file systems might have features built into them that would allow this kind of mapping from multiple clients, but the point is that the file system itself must support this kind of operation. – Tero Kilkanen Mar 10 '17 at 17:41
  • 1
    From the qemu book: "NB: never mount a QEMU image while QEMU is using it (unless -snapshot is used), or you are likely to corrupt the filesystem on the image." en.wikibooks.org/wiki/QEMU/Images#Mounting_an_image_on_the_host – Pablo Martinez Mar 10 '17 at 18:49
  • file systems are not designed to be mounted on two different machines simultaneously. Even if you could get it to "rescan" in read-only mode there is no guarantee that you could successfully read files as part of them might move or be appended to and you would have no idea how to tell. NFS would be the option to employ. – Alex Berry Mar 14 '17 at 15:50

Your Answer

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

Browse other questions tagged or ask your own question.