LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Mount a .img file (https://www.linuxquestions.org/questions/linux-general-1/mount-a-img-file-4175429177/)

chaz_d 09-26-2012 04:12 PM

Mount a .img file
 
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

acid_kewpie 09-26-2012 04:31 PM

well as that's an entire disk, not a single partition you can't mount it.

Have a look at how this guy found the partition offsets to mount a partition directly...
http://www.andremiller.net/content/m...ns-using-linux

rknichols 09-26-2012 06:02 PM

Another option:
kpartx - Create device maps from partition tables
Code:

# losetup -f --show some_file.img
/dev/loop0
# kpartx -a -v /dev/loop0
add map loop0p1 ...
add map loop0p2 ...
add map loop0p3 ...
.
.
.
#

Mountable devices will now be /dev/mapper/loop0p1, /dev/mapper/loop0p2, ... . Use "kpartx -d /dev/loop0" and "losetup -d /dev/loop0" to remove the mappings and free up the loop devices.

See the manpages for losetup and kpartx for more info.

jefro 09-26-2012 08:46 PM

I tend to use qemu to run that sort of file.


All times are GMT -5. The time now is 09:13 PM.