Extracting partitions from IMG

I’ve got an (.img) image of a DVD that contains multiple partitions, and I need to extract a ‘particular’ partition to sda4 (or a directory) on the HDD.

parted, which should display the start and end points of the partitions (which I would need for dd) just reports:

The Driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes [b]Ignore/Cancel[/b]
If I ignore I get an error... and I can find no way of forcing it to use a block size of 2048... if I enter:
sudo parted /path/to/img bs=2048

Then tell it to ‘print’, it ignores the bite size argument (with above error)… if i put bs=2048 before the path, it says it’s not a file.

If i dd the image to a partition:

sudo dd ~/image.img /dev/sda4 bs=2048

then mount sda4… all I can see is (what I’m guessing is) the FIRST partition, although All 8gb is reported by dd as being written… and sda4, although it WILL mount is reported by gparted as ‘unknown’ file system.

I need to either extract partition4 of the .img, or write partiton4 to sda4 on the HDD.

Or just find out the start and end points of the partitions within the .img

Any Ideas?

Ok… if I understand this correctly, the issue is that the .img contains a partition table … ?

What happens if you do this;

mkdir /mnt/tmp
losetup /dev/loop0 image.img
mount -o ro /dev/loop0p0 /mnt/tmp

Failing that, if losetup works, does it create any devices in /dev beginning with “loop0” ??
(obviously I’m expecting /dev/loop0p for each partition on the image, in which case amend the mount command accordingly)

after mount -o ro /dev/loop0p0 /mnt/tmp, it returns: mount: special device /dev/loop0p0 does not exist

but you’ve given me something else to throw at the problem :slight_smile:

after some research I found this:

the problem is that the "loop" device in the kernel is written to allow each instance of the driver to represent a block device (a container for a filesystem) like a partition, rather than a meta-block device (a container for block devices) like a disk.

I tried:

losetup -r -f image.img
losetup -a

and that returned:

/dev/loop0: [0802]:3409572 (/home/mark/image.img) /dev/loop1: [0802]:3409572 (/home/mark/image.img)
fdisk -l /dev/loop0


fdisk -l /dev/loop1

both return the same thing… the disk dimensions (7771mb, 255 heads etc.) and end with the line:

Disk /dev/loop0 doesn't contain a valid partition table Disk /dev/loop1 doesn't contain a valid partition table

To tell you the truth, I don’t NEED this problem solving… but if you’ve worked out what I’m doing, it would certainly help a lot of others :wink:

I’ve cracked it :slight_smile: … Will post in a bit how I did it :slight_smile:

it was an image of an Apple OSX DVD
here’s how: