Author Topic: Extracting partitions from IMG  (Read 7715 times)

0 Members and 1 Guest are viewing this topic.

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 18147
  • Karma: 473
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Extracting partitions from IMG
« on: April 28, 2010, 06:28:28 pm »
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:
Quote
The Driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes
Ignore/Cancel
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:
Code: [Select]
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:
Code: [Select]
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?
« Last Edit: April 28, 2010, 07:50:36 pm by Mark Greaves (PCNetSpec) »
WARNING: You are logged into reality as 'root'
logging in as 'insane' is the only safe option.
pcnetspec.co.uk

Offline Mad Penguin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1420
  • Karma: 10018
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: Extracting partitions from IMG
« Reply #1 on: April 29, 2010, 09:57:53 am »
Ok... if I understand this correctly, the issue is that the .img contains a partition table .. ?

What happens if you do this;

Code: [Select]
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<n> for each partition on the image, in which case amend the mount command accordingly)

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 18147
  • Karma: 473
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Extracting partitions from IMG
« Reply #2 on: April 29, 2010, 01:40:17 pm »
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 :)

after some research I found this:
Quote
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:
Code: [Select]
losetup -r -f image.img
losetup -a
and that returned:
Quote
/dev/loop0: [0802]:3409572 (/home/mark/image.img)
/dev/loop1: [0802]:3409572 (/home/mark/image.img)

Code: [Select]
fdisk -l /dev/loop0
and
Code: [Select]
fdisk -l /dev/loop1
both return the same thing... the disk dimensions (7771mb, 255 heads etc.) and end with the line:
Quote
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 ;)
WARNING: You are logged into reality as 'root'
logging in as 'insane' is the only safe option.
pcnetspec.co.uk

Offline Mark Greaves (PCNetSpec)

  • Administrator
  • Hero Member
  • *****
  • Posts: 18147
  • Karma: 473
  • Gender: Male
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
    • Awards
Re: Extracting partitions from IMG
« Reply #3 on: April 29, 2010, 02:22:22 pm »
I've cracked it :) ... Will post in a bit how I did it :)

[EDIT]
it was an image of an Apple OSX DVD
here's how:
http://linuxforums.org.uk/linux-tips-tricks/use-linux-to-install-osx-from-a-dmg-extracted-to-a-partition-without-a-mac-dvd/
« Last Edit: July 16, 2010, 04:30:26 pm by Mark Greaves (PCNetSpec) »
WARNING: You are logged into reality as 'root'
logging in as 'insane' is the only safe option.
pcnetspec.co.uk

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal