How to extract files from jffs2 rootfilesystem image ?

[ Note: following commands has been tried on ubuntu 16.04, but should work on other Linux distros as well ]

Lets create a temporary device node in /tmp as,

 $ sudo mknod /tmp/mtdblock0 b 31 0 
 $ ls -l /tmp/mtdblock0  

brw-r–r– 1 root root 31, 0 Aug 23 00:21 /tmp/mtdblock0

 $ sudo modprobe mtdblock 
 $ sudo modprobe mtdram total_size=65536 erase_size=256 
 $ sudo modprobe jffs2 

Now lets use dd command to write jffs2 binary rootfs to temporary device node we created at /tmp as,

 $ sudo dd if=/home/myuser/Downloads/rootfs.jffs2 of=/tmp/mtdblock0 

37888+0 records in
37888+0 records out
19398656 bytes (19 MB, 18 MiB) copied, 0.295502 s, 65.6 MB/s

 $ sudo mkdir /media/jffs2-extracted 

Now we will use a mount command for mounting jffs2 rootfs at /media/jffs2-extracted folder as,

 $ sudo mount -t jffs2 /tmp/mtdblock0 /media/jffs2-extracted 
 $ ls /media/jffs2-extracted/
bin  boot  dev  etc  home  lib  linuxrc  media  mnt  proc  sbin  sys  tmp  usr  var

This is how you can mount an jffs2 rootfs binary and extract the files from it.

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home HTML JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply