Your image is a disk image, not a filesystem image. The filesystem is on a partition inside that image (unless you did something really unusual). You can confirm this by running file Debian.raw
and fdisk -l Debian.raw
.
The easiest way to access this partition is to associate it with a loop device. If you can, make sure your loop
driver supports and is loaded with the max_parts
option; you may need to run rmmod loop; modprobe loop max_part=63
. Then associate the disk image with a loop device, and voilà:
losetup -fs Debian.raw # prints /dev/loop0 (or some other number)
mount /dev/loop0p1 /mnt # 0 as above, 1 is the partition number
If you can't get the loop driver to use partitions, you need to find out the offset of the partition in the disk image. Run fdisk -lu Debian.raw
to list the partitions and find out its starting sector S (a sector is 512 bytes). Then tell losetup
you want the loop device to start at this offset:
fdisk -lu Debian.raw # note starting sector $S
losetup -fs -o $(($S * 512)) Debian.raw
mount /dev/loop0 /mnt # /dev/loop0 or whatever losetup prints
If you want to copy the partition from the VM image to your system, determine its starting ($S
) and ending ($E
) offsets with fdisk -lu
as above. Then copy just the partition:
<Debian.raw tail -c +$((512*$S)) | dd of=/dev/sda5 bs=4M
(If the source and the destination are not on the same disk, don't bother with dd
, just redirect tail
's output to /dev/sda5
. If they are on the same disk, dd
with a large bs
parameter is a lot faster.)