Using Opensuse XEN for longer time I have not found an efficient way how to edit (import or export) data from disk image. For admin purposes I need time to time edit files in the disk image when domU stopped. Using mount -o for mounting domU image to dom0 filesystem is not working (type of filesystem is required and e2fsck -f does not help:
e2fsck: Superblock invalid, trying backup blocks…
e2fsck: Bad magic number in super-block while trying to open disk0.raw
Thank you in advance for any advice how to get and modify data on disk image when domU stopped.
Sorry for this question. This was my bad knowledge of Linux basics:
mount -o loop may be used but with the right value of the offset,
in my case: mount -o loop,offset=$((1896448 * 512)) disk0.raw /tmp/loop
I found good explanation here:
Hope it helps,
You could also use the xm command to do that:
xm block-attach 0 path/to/your/disk-image/disk0.raw xvda w
This will create the devices /dev/xvda1, /dev/xvda2 and so on for every partition on your raw disk image.
Assuming that the first partition is swap and the second is the root partition you can mount it with:
mount /dev/xvda2 /mnt
After you have done your changes you have to unmount the device and “detach” it from dom0:
xm block detach 0 /dev/xvda
Take a look at the xm man page.