LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to unpack a img file's file system? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-unpack-a-img-files-file-system-4175436185/)

chinabenjamin66 11-07-2012 10:00 PM

how to unpack a img file's file system?
 
Hello friends,

I want to unpack a img file via some unpackers, for example, unyaffs. unfortunately, after several attempts, without success. Can anyone help me? any reply will be appreciated, Thank you all.

by the way, How to detect the file system of a data file?

Quote:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# file OMG-German-4.0.4.img
OMG-German-4.0.4.img: data
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating#
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# /GPL/test/ufsd/pearl/firmware_unpack ./OMG-German-4.0.4.img
Unknown firmware ./OMG-German-4.0.4.img
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# /GPL/test/ufsd/pearl/firmware_unpack_x86_x64/firmware_unpack ./OMG-German-4.0.4.img
bash: /GPL/test/ufsd/pearl/firmware_unpack_x86_x64/firmware_unpack: cannot execute binary file

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# /GPL/test/ufsd/pearl/ehlers-unyaffs-44e4b2e/unyaffs ./OMG-German-4.0.4.img
Can't determine flash layout, perhaps not a yaffs2 image

## After this , I try to use ghex to find first human readable strings, so that I can calculate flash layout . unfortunately, find nothing.



So I guess it is a UBIFS image, try to mount it.
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# modprobe mtd
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# modprobe mtdblock
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# du -sh OMG-German-4.0.4.img
284M OMG-German-4.0.4.img
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte=0x15 ##512MiB, 2048 bytes page;
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating#
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# dd if=OMG-German-4.0.4.img of=/dev/mtdblock0 bs=2048
144935+1 records in
144935+1 records out
296828384 bytes (297 MB) copied, 47.96 s, 6.2 MB/s
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating#
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# ubiattach /dev/ubi_ctrl -m 0 -O 2048
ubiattach: error!: cannot attach mtd0
error 22 (Invalid argument)
####Why cannot mtd0 be attached?

Assume it is YAFFS2 file system image, try to mount it.

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# nandwrite -p /dev/mtd0 OMG-German-4.0.4.img
…..
Writing data to block 2203 at offset 0x11360000
Writing data to block 2204 at offset 0x11380000
Writing data to block 2205 at offset 0x113a0000
Writing data to block 2206 at offset 0x113c0000
Writing data to block 2207 at offset 0x113e0000
…..

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# mount -t yaffs2 /dev/mtdblock0
Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say man 8 mount .


evo2 11-07-2012 10:37 PM

Hi,

usually (unless you have a corresponding fstab entry) mount requires both a device and a mount point as arguments. Have you tried something like the following?
Code:

mkdir foo
mount -o loop OMG-German-4.0.4.img foo

Evo2.

chinabenjamin66 11-07-2012 11:54 PM

Hello evo2,

Yes, I have tried your code, I forgot to post it in the original thread.

See the output:
Quote:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# mount -o loop OMG-German-4.0.4.img /mnt
mount: you must specify the filesystem type

The problem is how to detect the file system of this img file.
Quote:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# file OMG-German-4.0.4.img
OMG-German-4.0.4.img: data


I only know it is a data file.

Regards.

evo2 11-08-2012 12:00 AM

Hi,

you should be able to get the filesystem type with fdisk. Eg
Code:

fdisk -l  OMG-German-4.0.4.img
Evo2.

PS. When posting text from your terminal please use [code] tags.

chinabenjamin66 11-08-2012 02:26 AM

Hello evo2,

Actually, I also have tried this code:

Code:
Code:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/fw_up# fdisk -l OMG-German-4.0.4.img

Disk OMG-German-4.0.4.img: 296 MB, 296827904 bytes
255 heads, 63 sectors/track, 36 cylinders, total 579742 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: 0x9924b140

Disk OMG-German-4.0.4.img doesn't contain a valid partition table
root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/fw_up#

You can see it does't contain a valid partition table.

Best Regards.

evo2 11-08-2012 03:15 AM

Hi,

well, if it fdisk doesn't see a partition table, presumably mount won't either. Do you have dosfs-tools (or whatever the equivalent package is on your distro) installed?

Evo2.

chinabenjamin66 11-08-2012 03:42 AM

Hello evo2,


The linux distribution I used:
Code:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# cat /proc/version
Linux version 3.2.0-31-generic-pae (buildd@roseapple) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #50-Ubuntu SMP Fri Sep 7 16:39:45 UTC 2012

I am not sure what kind of tools will be used, I click tab key using dos as wildcard.
Code:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# dosfs
dosfsck    dosfslabel



Benjamin.

evo2 11-08-2012 04:08 AM

Hi,

hmm, guess it is called dosfstools...
use your package manager. Eg
Code:

apt-cache search dosfstools
apt-cache show dosfstools
dpkg -l dosfstools

etc...

Evo2.

chinabenjamin66 11-08-2012 08:08 AM

Hello evo2,

Yes, follow your command, I try to install this package.

Code:

root@benjamin-virtual-machine:/home/benjamin# apt-get install dosfstools
Reading package lists... Done
Building dependency tree     
Reading state information... Done
dosfstools is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 201 not upgraded.
root@benjamin-virtual-machine:/home/benjamin# dosfs
dosfsck    dosfslabel

I type dosfs, and press TAB, it is not listed, what is the reason?
If dosfstools only contains dosfsck and dosfslabel, how are they used for unpacking the img file(OMG-German-4.0.4.img)?
And I viewed the manual of dosfsck and dosfslabel:

dosfsck - check and repair MS-DOS filesystems
dosfslabel - set or get MS-DOS filesystem label

Best regards
Benjamin.

michaelk 11-08-2012 08:55 AM

Just for clarification and since an img can mean just about anything what exactly does it contain? How was it created?

If it is a disk image of some sort post the output of the file command using the -s option i.e.:
file -s OMG-German-4.0.4.img

The -s is used for examining block devices.

schneidz 11-08-2012 09:14 AM

hi, according to the results of the file command in the original post, it does not seem to be a bootable disk image backup however this mite help:
http://www.linuxquestions.org/questi...le-4175430554/

chinabenjamin66 11-08-2012 07:41 PM

Quote:

Originally Posted by michaelk (Post 4825007)
Just for clarification and since an img can mean just about anything what exactly does it contain? How was it created?

If it is a disk image of some sort post the output of the file command using the -s option i.e.:
file -s OMG-German-4.0.4.img

The -s is used for examining block devices.



Hello michaelk,

Here is the output of 'file -s OMG-German-4.0.4.img':
Code:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/fw_up# file -s OMG-German-4.0.4.img
OMG-German-4.0.4.img: data

it is the same as the output of 'file OMG-German-4.0.4.img'

Nothing valuable information extracted.

chinabenjamin66 11-08-2012 07:46 PM

Quote:

Originally Posted by schneidz (Post 4825029)
hi, according to the results of the file command in the original post, it does not seem to be a bootable disk image backup however this mite help:
http://www.linuxquestions.org/questi...le-4175430554/

Hello schneidz,

I looked through the post you adviced, unfortunately, it still not work. anyway, thank you all.



Best regards
Benjamin.

chinabenjamin66 11-08-2012 09:26 PM

Hello schneidz,

Some guys suggest using qemu to open .img file, if it is a disk image. Unfortunately, this image format does not support checks.

Code:

root@gpl-vm:/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/fw_up# qemu-img check OMG-German-4.0.4.img
qemu-img: This image format does not support checks


Any ideas will be appreciated.


Best regards
Benjamin.

michaelk 11-09-2012 06:50 AM

Out of curiosity what is a PX-8805?

chinabenjamin66 11-09-2012 07:00 AM

Hi,

I don't know what it exactly stands for, probably it stands for index, I guess.

michaelk 11-09-2012 07:17 AM

Quote:

/GPL/test/ufsd/pearl/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# file OMG-German-4.0.4.img
I was looking for some background information based on your directory names i.e. .../PX-8805/PX-8805 firmware updating.

theNbomr 11-09-2012 10:41 AM

If the image is an image of a device, such as a flash disk with multiple partitions, then the funky kpartx tool may be what you need. There is a bit of instruction on backreference.org.

--- rod.

jefro 11-09-2012 03:19 PM

Why are bothering to check it? Use qemu -hd1 imagename.img

chinabenjamin66 11-10-2012 02:17 AM

Hi,

It seems a index or something like that.

schneidz 11-10-2012 11:36 AM

^ you need to ask the people you got the image file from what it is and how to use it.

at this point we pretty much determined it is not a standard image backup.

chinabenjamin66 11-14-2012 07:20 AM

Hello friends,

I tried this utilities, got some information about this image:
Code:

root@benjamin-virtual-machine:/GPL/PX-8805/Sourcecode_PX-8805/PX-8805 firmware updating# mkimage -l OMG-German-4.0.4.img
mkimage: Bad Magic Number: "OMG-German-4.0.4.img" is no valid image
Image Type : Davinci UBL Boot Image
UBL magic  : 80a2992a
Entry Point: 9863d046
nr of pages: 0462a224
start block: 95031e93
start page : 34b92a5d

Is this information helpful?


All times are GMT -5. The time now is 10:59 PM.