Hi, Chaz - you need to specify an offset. This is the boot sector getting
in your way.

Run 'fdisk -ul' on your .img file.  It will show you where the partitions
start:

fdisk -ul /dev/sda

Disk /dev/sda: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders, total 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d4ee3

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2         1026048    12582911     5778432   8e  Linux LVM
Partition 2 does not end on cylinder boundary.


That "Start" column is important.

Now, run "losetup -f -o $(( 512 * [offset] )) [file.img]" (don't copy those
square brackets literally).  This will give you a loop device to the acutal
partition you're interested in.

i.e.: losetup -f -o $(( 512 * 2048 )) /dev/sda

Now, you'll see:

losetup  -a
/dev/loop0: [0005]:6094 (/dev/sda), offset 1048576


A note: I did this on /dev/sda.  That's not going to do anything useful,
since /dev/sda1 is now the same as /dev/loop0.  I could probably get myself
into some fun problems with this setup.

On Wed, Sep 26, 2012 at 3:08 PM, Chaz <[email protected]> wrote:

> Hi,
>
> I'm having trouble mounting two .img files.
>
> I have tried mounting using "mount -oloop ...." and I have tried using
> losetup but nothing seems to be happening.
>
> I'm running OpenSUSE 12.1
>
> If I run the "file" command on both of them, this is what I get..
>
> CP_OS.img:      x86 boot sector; partition 1: ID=0x63, active,
> starthead 1, startsector 63, 71762292 sectors, code offset 0xc0
> IMAGE_DATA.img: x86 boot sector, Microsoft Windows XP MBR, Serial
> 0xfc139932; partition 1: ID=0x63, active, starthead 1, startsector 63,
> 143556777 sectors, code offset 0xc0
>
> As you can see, they are quite large files and I am desperate to get
> the data from them
>
> Does anybody have any ideas how I can get these mounted?  I would
> really appreciate it and may even buy you a drink, or some chocolates,
> or whatever takes your fancy...!
>
> Many thanks in advance
>
> --
> You received this message because you are subscribed to the Linux Users
> Group.
> To post a message, send email to [email protected]
> To unsubscribe, send email to [email protected]
> For more options, visit our group at
> http://groups.google.com/group/linuxusersgroup
> References can be found at: http://goo.gl/anqri
> Please remember to abide by our list rules (http://tinyurl.com/LUG-Rulesor
> http://cdn.fsdev.net/List-Rules.pdf)
>



-- 

           Daniel

-- 
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at 
http://groups.google.com/group/linuxusersgroup
References can be found at: http://goo.gl/anqri
Please remember to abide by our list rules (http://tinyurl.com/LUG-Rules or 
http://cdn.fsdev.net/List-Rules.pdf)

Reply via email to