I have a disk image
myimage.disk
which contains the partition table and a primary partition (i.e. a FAT32 filesystem). Think that as a USB pen image.I want to mount the primary partition to a local directory. I know how to mount a partition image using the loop utils but here I have disk image. My guess is that I have to mount the image 'skipping' the partition table but how can I do that?
![Linux Mount Vmdk Disk Image Linux Mount Vmdk Disk Image](/uploads/1/2/5/0/125028714/476671413.png)
Aug 5, 2007 - From the command line, change to a directory containing a VMware disk image (.vmdk file). Issue the following command (substituting the.
EmilianoEmiliano40833 gold badges88 silver badges1818 bronze badges
4 Answers
The kpartx tool makes this easier. It creates loop devices in /dev/mapper for each partition in your image. Then you can mount the loop device that corresponds with your desired partition without having to calculate the offset manually.
For example, to mount the first partition of the disk image:
When you're done with the image, remove the loop devices:
Alternatively, if you have a recent kernel, and pass loop.max_part=63 on boot (if loop is built-in) or to modprobe (if loop is a module), then you can do it this way:
When you're done with the loop:
Dmitry Grigoryev6,47511 gold badge2323 silver badges6060 bronze badges
scott.squiresscott.squires
Found this:
which seems exactly what I was looking for.
Here's the key part:
where the value of offset is in bytes. The suggested way to get the offset is to point
EmilianoEmilianoparted
at the image, then unit B for bytes and take the start value from the print output. As an alternative, assuming you have the disk space, do the obvious: once you have the offset and size, just use dd
to extract each partition to a separate file.40833 gold badges88 silver badges1818 bronze badges
spewspew
Nowadays you can minimize your work by using
udisks
. Solution from ArchWiki: udisks - Mount loop devicesTo easily mount ISO images, use the following command:
This will create a loop device and show the ISO image ready to mount. Once unmounted, the loop device will be terminated by udev.
-r
there for read only option.1,59944 gold badges1111 silver badges2323 bronze badges
ephemerrephemerr