LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-07-2012, 10:00 PM   #1
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Rep: Reputation: Disabled
Unhappy 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 .

Last edited by chinabenjamin66; 11-08-2012 at 02:29 AM.
 
Old 11-07-2012, 10:37 PM   #2
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Debian, SL
Posts: 5,106

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
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.
 
Old 11-07-2012, 11:54 PM   #3
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
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.

Last edited by chinabenjamin66; 11-08-2012 at 02:30 AM.
 
Old 11-08-2012, 12:00 AM   #4
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Debian, SL
Posts: 5,106

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
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.
 
Old 11-08-2012, 02:26 AM   #5
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-08-2012, 03:15 AM   #6
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Debian, SL
Posts: 5,106

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
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.
 
Old 11-08-2012, 03:42 AM   #7
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
Smile

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.
 
Old 11-08-2012, 04:08 AM   #8
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Debian, SL
Posts: 5,106

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
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.
 
Old 11-08-2012, 08:08 AM   #9
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-08-2012, 08:55 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,816

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
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.
 
Old 11-08-2012, 09:14 AM   #11
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 3,847

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
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/
 
Old 11-08-2012, 07:41 PM   #12
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
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.
 
Old 11-08-2012, 07:46 PM   #13
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
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.
 
Old 11-08-2012, 09:26 PM   #14
chinabenjamin66
Member
 
Registered: Mar 2012
Location: Shenzhen Chian
Posts: 73

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-09-2012, 06:50 AM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,816

Rep: Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724Reputation: 724
Out of curiosity what is a PX-8805?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert an ISO file into an IMG file chris6686 Linux - Newbie 6 12-04-2011 08:11 PM
[SOLVED] Mounting .img file (chromiumos.img); can't mount it?? Help please? linus72 Linux - General 2 11-27-2009 08:11 PM
how to convert a .iso file to .img file mobquest Linux - Newbie 1 07-10-2009 04:59 AM
make a .img file for custom liveCD, dd?? (Also, how to make your system very small) 1veedo Linux - Newbie 6 05-07-2006 05:52 PM
Uncompress + Unpack files: (Read Only File System) ptreves Linux - Newbie 8 08-16-2004 02:52 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration