maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia 770 (https://talk.maemo.org/forumdisplay.php?f=24)
-   -   How do i combine initfs and rootfs for a complete installation? (https://talk.maemo.org/showthread.php?t=21028)

benny1967 2008-06-16 08:58

How to extract rootfs.jffs2 directly to mmc card for dual-boot
 
There are plenty of threads here explaining how to clone the OS from internal memory to the MMC/SD-card.

What I want to do is a little different: I want to leave the running OS 2006 on my 770 untouched, use the boot-menu (already have this *g*) and get a working image of OS2007HE on my MMC card. (I have a crad reader on my desktop linux PC, so it's really easy for me to do all the steps there.)

Unfortunately, I don't get very far. I had some more problems in the beginning (thread here) and benson helped me a lot during these ealry steps, but I'm still stuck on how to get a working setup on the MMC-partition:

I can easily extract the contents of both rootfs.jffs2 and initfs.jffs2 on my desktop PC, but how do I combine them to get a running system?

First I thought rootfs.jffs2 would be enough, but it isnt. Then I added the contents of initfs.jffs2 to /mnt/initfs in the root fs, but it still doesnt boot.

Anybody done this before? What am I missing?

And: Is there any place I can go for debugging information? I get the boot menu, select the entry, and after a few seconds I'm at the boot menu again... Not very helpful. Is there a way to read what happened afterwards? Like missing modules, wrong paths etc etc...?

It would be so cool to just copy whatever version of ITOS to MMC without going through the "flash-copy to MMC-reflash original"-hassle. I'd even consider OS2005 just for the fun of it - I can't remeber what it looked like at all. ;)

fanoush 2008-06-16 09:18

Re: How do i combine initfs and rootfs for a complete installation?
 
Quote:

Originally Posted by benny1967 (Post 192474)
I can easily extract the contents of both rootfs.jffs2 and initfs.jffs2 on my desktop PC

How exactly you did it?

Quote:

Originally Posted by benny1967 (Post 192474)
but how do I combine them to get a running system?

You don't need to. BTW title of this thread is misleading, something like "How to extract jffs2 directly to mmc card" would be better.

First I thought you need to combine them to make flashable FIASCO image.

Quote:

Originally Posted by benny1967 (Post 192474)
First I thought rootfs.jffs2 would be enough, but it isnt.

Yes, it should be enough. If not, you are doing something wrong when extracting jffs2.

Quote:

Originally Posted by benny1967 (Post 192474)
It would be so cool to just copy whatever version of ITOS to MMC without going through the "flash-copy to MMC-reflash original"-hassle. I'd even consider OS2005 just for the fun of it - I can't remeber what it looked like at all. ;)

It is not possible in general. Only rootfs is on SD/MMC card, kernel, initfs not => you cannot boot systems that use different kernel and initfs (like OS2007 vs 8 on N8x0, OS2005 vs 6 on 770).

As for extracting rootfs from FIASCO image and then extracting jffs2 to MMC on the fly directly on the tablet, it is possible but complicated. You need 0xFFFF flasher for extraction FIASCO and block2mtd kernel driver (+dependencies) for mounting jffs2 image.

Here is my simple (=it may not work for you) script for mounting jffs2 on linux PC
Code:

if [ `id -u` != 0 ] ; then
    echo "run this as root"
    exit
fi
if [ $# -lt 2 ] ; then
    echo $0 image.jffs2 directory
    exit
fi
LOOPDEV=`losetup -f`
losetup $LOOPDEV $1
modprobe block2mtd block2mtd=$LOOPDEV,131072
modprobe jffs2
modprobe mtdblock
sleep 1
[ -d $2 ] || mkdir $2
mount -t jffs2 -o ro /dev/mtdblock0 $2


benny1967 2008-06-16 09:49

Re: How do i combine initfs and rootfs for a complete installation?
 
Answers from the master himself. Great! :)

Quote:

Originally Posted by fanoush (Post 192475)
How exactly you did it?

I cant reproduce the exact steps ATM because I'm not at my box, but from what I remember I
  1. unpacked the contents of the 2007HE fiasco image using Nokias flasher tool
  2. mounted rootfs.jffs2 to some directory (all the block2mtd / losetup...-magic applies)
  3. copied everything from there to MMC


Quote:

Originally Posted by fanoush (Post 192475)
Yes, it should be enough. If not, you are doing something wrong when extracting jffs2.

This is the most important information. Thank you!
Not knowing if rootfs.jffs2 would be enough or if somehow contents from initfs.jffs2 are required (like for additional kernel modules etc.) left me in empty space with too many possible combinations for trial and error.

Quote:

Originally Posted by fanoush (Post 192475)
It is not possible in general. Only rootfs is on SD/MMC card, kernel, initfs not => you cannot boot systems that use different kernel and initfs (like OS2007 vs 8 on N8x0, OS2005 or 6 vs 770).

Logical consequence... so, how about OS2007HE and OS2006, then? IIRC, in recent HE, the kernel is basically the same as in OS2006, but they did apply changes to the initfs? Could this be the reason it doesn't work? Or is it known that OS2007HE can dual-boot from MMC on a system that uses a OS2006-initfs?

fanoush 2008-06-16 10:18

Re: How do i combine initfs and rootfs for a complete installation?
 
Quote:

Originally Posted by benny1967 (Post 192476)
Logical consequence... so, how about OS2007HE and OS2006, then? IIRC, in recent HE, the kernel is basically the same as in OS2006, but they did apply changes to the initfs? Could this be the reason it doesn't work? Or is it known that OS2007HE can dual-boot from a system that uses a OS2006-initfs?

Luckily few last OS2006 versions and any hacker edition so far use same kernel and same initfs (minus fixed wi-fi drver in 2007HE initfs).

once jffs2 image is properly mounted, there is no catch, just straight tar clone (as root) directly to mounted mmc should do it.

Mind the 131072 eraseblocks size constant in block2mtd insmod call, it is important. And watch kernel log for any errors about image size when mounting jffs2 and after tar copy. Also mount it in read only mode (-o ro) just to be safe, if you already mounted it once in rw mode, extract it from FIASCO again just to be sure you still have original data.

benny1967 2008-06-16 10:36

Re: How do i combine initfs and rootfs for a complete installation?
 
Quote:

Originally Posted by fanoush (Post 192478)
Mind the 131072 eraseblocks size constant in block2mtd insmod call, it is important. And watch kernel log for any errors about image size when mounting jffs2 and after tar copy. Also mount it in read only mode (-o ro) just to be safe, if you already mounted it once in rw mode, extract it from FIASCO again just to be sure you still have original data.

OK, when I'm home I'll try again and start from the FIASCO-image to make sure everything's OK.
This was really very helpful, fanoush, thank you. I still don't know if it will work, but at least there's a lot of new information: I know it *should* work. I know only rootfs is necessary. And I know some things to pay attention to when copying the contents of the *.jffs2-file. - The future looks brighter now. :D

benny1967 2008-06-16 19:59

Re: How do i combine initfs and rootfs for a complete installation?
 
Works!

Thank you so much. I have no idea what went wrong before, but I assume the problem was somehow related to extracting/copying the files from the jffs2-file:
IIRC, it did this only once and used they resulting files for all my attempts. I was so sure that I needed to find the right parts from initfs to go with the rootfs that it never once occured to me the cause of the problem could be something completely different.

artgopi 2008-06-17 00:12

Re: How do i combine initfs and rootfs for a complete installation?
 
I've been trying to do this for some time but I was unsuccessful.

benny1967 could you please post the the commands you use?
I've tried what you mentioned earlier but the ITT fail to boot.
Tanks

benny1967 2008-06-17 17:54

Re: How do i combine initfs and rootfs for a complete installation?
 
@art:
I hope I can remember what I did... It's basically all in fanoush's post above, though (his script):

First I unpack the fiasco image:
Code:

flasher-3.0 -u -F SU-18_2007HACKER_4.2007.46-3_PR_F5_MR0_ARM.bin
One of the files I get is rootfs.jffs2. I used this one and deleted everything else that was in the image.
Then I find a free loop device (usually /dev/loop0) with "losetup -f" and attach the rootfs-file to it:
Code:

losetup /dev/loop0 rootfs.jffs2
Next I set up the block2mtd-module to work with the loop device. Honestly, I have no idea what all these things are... I just do as I'm told:
Code:

modprobe block2mtd block2mtd=/dev/loop0,131072
I didnt do the "modprobe jffs2", "modprobe mtdblock" because those are not modules in my kernel; normally you will have them as modules and use modprobe as described by fanoush.
(I learned that you have to compile block2mtd as a module, though, otherwise you can't cleanly undo all of this.)

Next you mount the device:
Code:

mount -t jffs2 -o ro /dev/mtdblock0 /mnt/jffs2/
For the following step, I assume your MMC-card is mounted on /media/disk/:

Copy the contents of the jffs2 to the card with:
Code:

tar -cf -  -C /mnt/jffs . | tar xvf - -C /media/disk
(/mnt/jffs is the source, /media/disk the target)
Again, I did what I read on maemo.org. I'm not really sure why "cp -a" or something similar will not do, they say you need to use tar or rsync. That's how it works...

Another thing that was strange: The unpacked rootfs has <200MB; the partition on my MMC was set to 256MB or so, IIRC. Still, very early in the copy-process, I got error messages about the target being full... "df" showed 70% free on the partition afterwards. I had no time to investigate, deleted a second partition and created a new one with 700MB - now it works.

ramsarvan 2009-01-06 16:16

Re: How do i combine initfs and rootfs for a complete installation?
 
Hi Fanoush,

Thanks for the script.
I was able to mount my jffs2 filesystem in Linux.
I have a small issue. After mounting, if i remove
a folder say X of size 12 MB and add another
folder of 16 MB, the cp fails and says No free
space left in device. How can I tackle this issue?

If i check with df util, it says my mount folder
is 100% used. Any idea?

Thanks a lot,
Ram

qwerty12 2009-01-06 16:18

Re: How do i combine initfs and rootfs for a complete installation?
 
Tar it up and extract to another location and use mkfs.jffs2 to make a new jffs2 image.


All times are GMT. The time now is 17:29.

vBulletin® Version 3.8.8