<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=128.30.25.168</id>
	<title>Maemo Wiki Mirror - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=128.30.25.168"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/128.30.25.168"/>
	<updated>2026-04-22T05:55:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=Modifying_the_root_image&amp;diff=26763</id>
		<title>Modifying the root image</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=Modifying_the_root_image&amp;diff=26763"/>
		<updated>2008-08-01T16:38:20Z</updated>

		<summary type="html">&lt;p&gt;128.30.25.168: /* Kernel memory emulating an MTD device */ Fixed link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article describes two methods for extending and modifying an existing tablet JFFS2 root image.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
The root filesystem (rootfs) of the tablets is stored in a Journal Flash File System version 2 (JFFS2) format. It resides on one of the partitions on the flash chip in the device. Additionally, a pristine version of the rootfs can be obtained from the [http://tablets-dev.nokia.com/ Nokia official firmware] site.&lt;br /&gt;
&lt;br /&gt;
There are two ways to mount the JFFS2 image:&lt;br /&gt;
#Have a block device emulate a Memory Technology Device (MTD) via block2mtd.&lt;br /&gt;
#Have kernel memory emulate a MTD via mtdram.&lt;br /&gt;
&lt;br /&gt;
== Getting the JFFS2 image ==&lt;br /&gt;
First of all, we need to get the rootfs.jffs2 from the official [http://tablets-dev.nokia.com/ Nokia FIASCO image]. After downloading the FIASCO image, run this on it to unpack it (this will give you all of the individual parts of the image):&lt;br /&gt;
&lt;br /&gt;
 sudo ./flasher-3.0 --unpack  -F &amp;lt;FIASCO image&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Mounting the JFFS2 image ==&lt;br /&gt;
These commands will be executed with root privileges on the host machine and not on the device itself.&lt;br /&gt;
&lt;br /&gt;
=== Block device emulating an MTD device ===&lt;br /&gt;
You must have the following kernel modules compiled and installed:&lt;br /&gt;
&lt;br /&gt;
*CONFIG_MTD (mtdcore) &lt;br /&gt;
*CONFIG_MTD_PARITIONS (mtdpart) &lt;br /&gt;
*CONFIG_MTD_MTDRAM (mtdram) &lt;br /&gt;
*CONFIG_MTD_BLOCK2MTD (block2mtd) &lt;br /&gt;
*CONFIG_BLK_DEV_LOOP (loop) &lt;br /&gt;
&lt;br /&gt;
I suggest you do not make these modules statically linked into the kernel. It is more practical to be able to unload these modules when not needed or when you want to start over from scratch.&lt;br /&gt;
&lt;br /&gt;
You will use the loopback device (/dev/loop[0-15]) to simulate a block device whose contents are from the JFFS2 image. To mount the JFFS2 image, you perform the following steps:&lt;br /&gt;
&lt;br /&gt;
 mknod /tmp/mtdblock0 b 31 0&lt;br /&gt;
 modprobe loop&lt;br /&gt;
 losetup /dev/loop0 rootfs.jffs2&lt;br /&gt;
 modprobe mtdblock&lt;br /&gt;
 modprobe block2mtd&lt;br /&gt;
 echo &amp;quot;/dev/loop0&amp;quot; &amp;gt; /sys/module/block2mtd/parameters/block2mtd&lt;br /&gt;
 modprobe jffs2&lt;br /&gt;
 mount -t jffs2 /tmp/mtdblock0 /media/jffs2&lt;br /&gt;
&lt;br /&gt;
To unmount and cleanup:&lt;br /&gt;
&lt;br /&gt;
 umount /media/jffs2&lt;br /&gt;
 modprobe -r block2mtd&lt;br /&gt;
 modprobe -r mtdblock&lt;br /&gt;
 losetup -d /dev/loop0&lt;br /&gt;
&lt;br /&gt;
Or use the [[#Shell_script_to_mount/unmount_JFFS2_using_block_device_emulating_MTD|automated shell script]].&lt;br /&gt;
&lt;br /&gt;
=== Kernel memory emulating an MTD device ===&lt;br /&gt;
To mount the JFFS2 image, you perform the following steps:&lt;br /&gt;
&lt;br /&gt;
 mknod /tmp/mtdblock0 b 31 0&lt;br /&gt;
 modprobe mtdblock&lt;br /&gt;
 modprobe mtdram total_size=65536 erase_size=256&lt;br /&gt;
 modprobe jffs2&lt;br /&gt;
 dd if=/pathtoimage/rootfs.jffs2 of=/tmp/mtdblock0&lt;br /&gt;
 mkdir /media/jffs2&lt;br /&gt;
 mount -t jffs2 /tmp/mtdblock0 /media/jffs2&lt;br /&gt;
&lt;br /&gt;
To unmount and cleanup:&lt;br /&gt;
&lt;br /&gt;
 umount /media/jffs2&lt;br /&gt;
 modprobe -r jffs2&lt;br /&gt;
 modprobe -r mtdram&lt;br /&gt;
 modprobe -r mtdblock&lt;br /&gt;
&lt;br /&gt;
Or use the [[Modifying_the_root_image#Shell_script_to_mount.2Funmount_JFFS2_using_kernel_memory_emulating_MTD|automated shell script]].&lt;br /&gt;
&lt;br /&gt;
== Archiving and extracting the rootfs image ==&lt;br /&gt;
The image is now accessible under /media/jffs2. Copy the whole image to another directory. This new directory will be used for modifying the image. Extending the currently mounted JFFS2 image is not suggested. Using cp for copying the image to a working directory won&#039;t work due to special files in /media/jffs2/dev, which is why we use tar. &lt;br /&gt;
&lt;br /&gt;
 cd /media/jffs2&lt;br /&gt;
 tar cvzf /my_path/myRootImage.tar.gz .&lt;br /&gt;
 cd $HOME&lt;br /&gt;
 mkdir myRootImage&lt;br /&gt;
 cd myRootImage&lt;br /&gt;
 tar xvpzf /my_path/myRootImage.tar.gz&lt;br /&gt;
&lt;br /&gt;
== Repacking the image ==&lt;br /&gt;
[http://maemo.org/development/documentation/how-tos/2-x/howto_use_flasher_rootfs.html Using the flasher utility and creating the reference root file system]&lt;br /&gt;
&lt;br /&gt;
== Modifying the copy of the image ==&lt;br /&gt;
Now the image is successfully archived and copied. The working directory  $HOME/myRootImage can now be used for adding, changing or modifying packages.&lt;br /&gt;
&lt;br /&gt;
 cd $HOME/myRootImage&lt;br /&gt;
 dpkg -x $HOME/arm_debs/mypackage_arm.deb .&lt;br /&gt;
&lt;br /&gt;
Now we create a new tarball from the working directory of the image.&lt;br /&gt;
&lt;br /&gt;
 cd $HOME/myRootImage&lt;br /&gt;
 tar cvzf $HOME/myNewRootImage.tar.gz .&lt;br /&gt;
&lt;br /&gt;
== Installing on the tablet ==&lt;br /&gt;
When the new tarball is created,  Using flasher and the reference root filesystem for creating JFFS2 image from the myNewRootImage.tar.gz.&lt;br /&gt;
&lt;br /&gt;
Use flasher to install the image on the tablet.&lt;br /&gt;
&lt;br /&gt;
 ./flasher-3.0 -r rootfs.jffs2 --f -R&lt;br /&gt;
&lt;br /&gt;
== Shell script to mount/unmount JFFS2 using block device emulating MTD ==&lt;br /&gt;
Create a shell script (mount_jffs2.sh) from the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 JFFSIMG=$1 # jffs image&lt;br /&gt;
 LOOP=&amp;quot;/dev/loop1&amp;quot; # loop device&lt;br /&gt;
 MP=&amp;quot;/media/jffs2&amp;quot; # mount point&lt;br /&gt;
 MTDBLOCK=&amp;quot;/tmp/mtdblock0&amp;quot; # MTD device file&lt;br /&gt;
 KVER=&amp;quot;2.6&amp;quot;&lt;br /&gt;
 BLKMTD=&amp;quot;block2mtd&amp;quot;&lt;br /&gt;
 UMNT=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;$0&amp;quot; | grep unmount_ &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 [ $? -eq 0 ] &amp;amp;&amp;amp; UMNT=1&lt;br /&gt;
 if [ $# -gt 1 -a x&amp;quot;$2&amp;quot;x = x&amp;quot;unmount&amp;quot;x ]; then&lt;br /&gt;
   UMNT=1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 uname -r | egrep &#039;^2\.6&#039; &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 if [ $? -ne 0 ]; then&lt;br /&gt;
   KVER=&amp;quot;2.4&amp;quot;&lt;br /&gt;
   BLKMTD=blkmtd&lt;br /&gt;
 fi &lt;br /&gt;
&lt;br /&gt;
 if [ x&amp;quot;${UMNT}&amp;quot;x = x&amp;quot;&amp;quot;x ]; then&lt;br /&gt;
   if [ ! -b ${MTDBLOCK} ] ; then&lt;br /&gt;
     mknod ${MTDBLOCK} b 31 0 || exit 1&lt;br /&gt;
   fi&lt;br /&gt;
   lsmod | grep loop &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
   if [ $? -ne 0 [; then&lt;br /&gt;
     modprobe loop&lt;br /&gt;
     [ $? -ne 0 ] &amp;amp;&amp;amp; echo &amp;quot;loopback loading failed&amp;quot; &amp;amp;&amp;amp; exit 1&lt;br /&gt;
     sleep 1&lt;br /&gt;
   fi&lt;br /&gt;
   losetup ${LOOP} ${JFFSIMG} || exit 1&lt;br /&gt;
   sleep 1&lt;br /&gt;
   modprobe mtdblock&lt;br /&gt;
   if [ x&amp;quot;${KVER}&amp;quot;x = x&amp;quot;2.4&amp;quot;x [; then&lt;br /&gt;
     modprobe ${BLKMTD} device=${LOOP} || exit 1&lt;br /&gt;
   else&lt;br /&gt;
     modprobe ${BLKMTD} || exit 1&lt;br /&gt;
     echo &amp;quot;${LOOP}&amp;quot; &amp;gt; /sys/module/block2mtd/parameters/block2mtd&lt;br /&gt;
   fi&lt;br /&gt;
   sleep 1&lt;br /&gt;
   modprobe jffs2&lt;br /&gt;
   [ ! -d ${MP} ] &amp;amp;&amp;amp; mkdir -p ${MP}&lt;br /&gt;
   mount -t jffs2 ${MTDBLOCK} ${MP} || exit 1&lt;br /&gt;
 else&lt;br /&gt;
   umount ${MP}&lt;br /&gt;
   if [ $? -ne 0 ]; then&lt;br /&gt;
     echo &amp;quot;Cannot unmount JFFS2 at $MP&amp;quot; &amp;amp;&amp;amp; exit 1&lt;br /&gt;
   fi&lt;br /&gt;
   modprobe -r jffs2&lt;br /&gt;
   modprobe -r ${BLKMTD}&lt;br /&gt;
   modprobe -r mtdblock&lt;br /&gt;
   sleep 1&lt;br /&gt;
   losetup -d ${LOOP}&lt;br /&gt;
 fi &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Make sure you chmod a+x mount_jffs2.sh to make the shell script executable.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;br /&gt;
 ./mount_jffs2.sh rootfs.jffs2&lt;br /&gt;
&lt;br /&gt;
You can also use this script to unmount and unload the non-utilized kernel modules and loopback reference:&lt;br /&gt;
 ./mount_jffs2.sh rootfs.jffs2 unmount&lt;br /&gt;
&lt;br /&gt;
== Shell script to mount/unmount JFFS2 using kernel memory emulating MTD ==&lt;br /&gt;
Create a shell script (mount_jffs2.sh) from the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 JFFSIMG=$1 # jffs image&lt;br /&gt;
 MP=&amp;quot;/media/jffs2&amp;quot; # mount point&lt;br /&gt;
 MTDBLOCK=&amp;quot;/tmp/mtdblock0&amp;quot; # MTD device file&lt;br /&gt;
 UMNT=&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;$0&amp;quot; | grep unmount_ &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 [ $? -eq 0 ] &amp;amp;&amp;amp; UMNT=1&lt;br /&gt;
 if [ $# -gt 1 -a x&amp;quot;$2&amp;quot;x = x&amp;quot;unmount&amp;quot;x ]; then&lt;br /&gt;
   UMNT=1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 if [ x&amp;quot;${UMNT}&amp;quot;x = x&amp;quot;&amp;quot;x ]; then&lt;br /&gt;
   if [ ! -b ${MTDBLOCK} ] ; then&lt;br /&gt;
     mknod ${MTDBLOCK} b 31 0 || exit 1&lt;br /&gt;
   fi&lt;br /&gt;
   modprobe mtdblock&lt;br /&gt;
   modprobe mtdram total_size=65536 erase_size=256&lt;br /&gt;
   modprobe jffs2&lt;br /&gt;
   dd if=${JFFSIMG} of=${MTDBLOCK}&lt;br /&gt;
   [ ! -d ${MP} ] &amp;amp;&amp;amp; mkdir -p ${MP}&lt;br /&gt;
   mount -t jffs2 ${MTDBLOCK} ${MP}&lt;br /&gt;
 else&lt;br /&gt;
   umount ${MP}&lt;br /&gt;
   if [ $? -ne 0 ]; then&lt;br /&gt;
     echo &amp;quot;Cannot unmount JFFS2 at $MP&amp;quot; &amp;amp;&amp;amp; exit 1&lt;br /&gt;
   fi&lt;br /&gt;
   modprobe -r jffs2&lt;br /&gt;
   modprobe -r mtdram&lt;br /&gt;
   modprobe -r mtdblock&lt;br /&gt;
 fi &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Make sure you chmod a+x mount_jffs2.sh to make the shell script executable.&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
 ./mount_jffs2.sh rootfs.jffs2&lt;br /&gt;
&lt;br /&gt;
You can also use this script to unmount and unload the non-utilized kernel modules:&lt;br /&gt;
 ./mount_jffs2.sh rootfs.jffs2 unmount&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTos]]&lt;br /&gt;
[[Category:Wiki page of the day]]&lt;/div&gt;</summary>
		<author><name>128.30.25.168</name></author>
	</entry>
</feed>