73.6. How to access to the VM's files

To access to the files of the virtual machine you can use the loopback device.

  1. Create a new directory (example: mkdir /opt/domains/myvirtualmachine/loop).

  2. Check the disk partitons using fdisk (fdisk -lu /opt/domains/myvirtualmachine/image.img).

  3. The offset of the partition correspond to the number of offset sectors of the partition multiplied by 512 (Example: if the offset sectors are 208845, the partition offset is 208845 * 512 = 106928640).

  4. Assign the partition to the device /dev/loop0 with the command losetup -o <partition-offset> /dev/loop0 <disk-image-file> (Example: losetup -o 106928640 /dev/loop0 /opt/domains/myvirtualmachine/image.img).

  5. Mount the device into the previously created directory mount /dev/loop0 /opt/domains/myvirtualmachine/loop.

When you have finished the operations on the files, unmount the device using the command umount /opt/domains/myvirtualmachine/loop && losetup -d /dev/loop0.