I am interested in mounting a firmware image and browsing its contents. I attempted this with the mount command but received some errors ("you must specify filesystem type"). However I think there may be other issues here. I believe the below information should be all that I need to accomplish this, I'm just not sure what to do with this information.

How can I mount this .img file and browse its contents?

Running file

/root/Downloads/FW_WRT1900AC_1.1.8.164461_prod.img: u-boot legacy uImage, Linux-3.2.40, Linux/ARM, OS Kernel Image (Not compressed), 3856080 bytes, Thu Nov 20 13:45:36 2014, Load Address: 0x00008000, Entry Point: 0x00008000, Header CRC: 0x5CAE7F84, Data CRC: 0xFCF78543

Running fdisk -l

Disk /root/Downloads/FW_WRT1900AC_1.1.8.164461_prod.img: 26 MB, 26345472 bytes
255 heads, 63 sectors/track, 3 cylinders, total 51456 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: 0x80811005

Disk /root/Downloads/FW_WRT1900AC_1.1.8.164461_prod.img doesn't contain a valid partition table
  • What mount command did you try exactly? – terdon Feb 28 '15 at 11:48
  • can you show the full mount command you tried, arguments, options, and all? – Skaperen Feb 28 '15 at 11:53
  • @Skaperen This isn't a filesystem image (it's possibly the concatenation of a kernel image and filesystem image), so mount alone isn't enough anyway. – Gilles 'SO- stop being evil' Feb 28 '15 at 22:56

The first 3856080 bytes of this file is a kernel image. After that, there is a filesystem image. The filesystem is at offset 3932160 (3856080 rounded up to the next multiple of 128kB); I found it by inspection, I don't know where the information is stored in the image (it may be related to the erase size on the intended device). The filesystem is JFFS2, which is common on such devices.

JFFS2 filesystems cannot be mounted directly on Linux, because the filesystem driver requires the filesystem to be on top of an MTD device. You can use a fake MTD device in RAM to work around this limitation. You need to extract the JFFS2 image from the boot image; it has to be an integer number of erase blocks. In a nutshell:

modprobe mtdram total_size=32768 erase_size=128
modprobe mtdblock
<FW_WRT1900AC_1.1.8.164461_prod.img tail -c +3932161 | head -c 22413312 >/dev/mtdblock0
mount -t jffs2 /dev/mtdblock0 /mnt

Alternatively, you can use the programs jffs2dump and jffs2reader from the MTD utilities.

<FW_WRT1900AC_1.1.8.164461_prod.img tail -c +3932161 | head -c 22413312 >|FW_WRT1900AC_1.1.8.164461_prod.jffs2
jffs2reader FW_WRT1900AC_1.1.8.164461_prod.jffs2 >FW_WRT1900AC_1.1.8.164461_prod.contents
jffs2reader FW_WRT1900AC_1.1.8.164461_prod.jffs2 -d /
jffs2reader FW_WRT1900AC_1.1.8.164461_prod.jffs2 -f /etc/version
|improve this answer|||||
  • Can I still read it if the image is bigger than my RAM size? – Alex Jun 3 '17 at 22:28
  • @Alex With jffs2reader it doesn't matter. With mdtram the image does need to fit in RAM. – Gilles 'SO- stop being evil' Jun 3 '17 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.