Monday, April 7, 2008

Dual Booting OS 2008 Step 3: The Actual Dual boot

Ok, so now we have root access, we have a partitioned mmc/sd card.. we are ready for the cool part.

First things first, either plug in your tablet or make sure you have a full battery, you don't want the power to go out during this part.

From the tablet you need to download this;
http://fanoush.wz.cz/maemo/initfs_flasher.tgz

(for more information about fanoush's work and info on this flasher, see http://fanoush.wz.cz/maemo/#initfs)

By default the tablet will want to save to your Documents folder in your /home directory (/home/user/MyDocs/.documents/)

Don't save it on your card, not because that will cause problems, but because you can't execute applications by default from your cards. This program is going to replace the initfs section of the device with the dual boot, but first lets look at that extension...tgz

This means that this is a tar file, compressed with gzip compression.. if it read tar.gz it would mean the same thing. In linux file extensions don't mean anything. They are just there to help the user know what to do with the file.

We are going to use the version of tar that comes with the tablet to open this file. This will probably be the last time we use that version, more on this later.

In xterm as root run the following;

cd /home/user/MyDocs/.documents
tar xvzf initfs_flasher.tgz
cd initfs_flasher
./initfs_flash

The first command (cd) Changes Directory to your documents folder. The "." before a file or directory means its a hidden file and won't show up in a listing with out the -a switch (google for "manpage ls" for more info). The second command opens the archive file the switch (xvzf) means X=extract V=verbose(more info) Z=gzip format F=specified file. Then we are switching into the directory that we just extracted, and finally we are running a local application (./). Unix uses something called your "PATH" (try "echo $PATH" at xterm). The path is where the system looks for executables. Since your documents folder isn't in your path, we tell the system to run the local app directly (./ means "here" ../ means "one level above me" ../../ "two levels above" and so on and so forth)

Read the applications instructions carefully, but you should be safe answering yes to all the questions.

When it says press enter to reboot.. do so. If upon boot for some strange reason your highlighted selection is not "internal flash" hit the menu key, and then the up key to highlight it, then hit the square button. If it is highlighted, you can either wait the 30 seconds for the menu to finish, or hit the menu key, then the square key.

Congratulations! You can now dual-boot, but dual boot to what? Continued Next Time.

Just kidding.. man wouldn't that have sucked!

We are going to copy the whole rootfs over to the card. Remember when I talked about that other version of tar.. well here it is. We are going to use GNUtar.. it has more features.. though it will look and feel pretty much the same.

To install, open Xtem, and run this command

apt-get -d install tar

Apt-get is the front end for dpkg, the debian package managment software, and we are telling it to fetch and install tar...well almost. See that -d? That means download only. In this case that is 147% important! Without that it will delete your whole system and you will have to flash and start over. Don't be worried though, just double check for the -d before you hit enter.

If you made sure the -d was there you can ignore the warnings and go ahead and enter "Y".

Once it has downloaded, we will run the following commands as root in an xterm.

cd /var/cache/apt/archives/
mkdir /tar-temp/
dpkg -x tar*.deb /tar-temp/

Ok, you already know what the cd command does. The mkdir command makes a new directory where you tell it to. This new directory we are making is called tar-temp, and it is being made in the top level directory "/" also called the root. The last command uses the debian package management software to extract the tar program to that directory.

Now we need to mount our partitions to locations that we can copy over the files

Again, as root in an xterm;

insmod /mnt/initfs/lib/modules/2.6.18-omap1/mbcache.ko (this is .21-omapl in OS2008)
insmod /mnt/initfs/lib/modules/2.6.18-omap1/ext2.ko
mkdir /opt/
mount /dev/mmcblk0p2 /opt
mkdir /floppy/
mount -t jffs2 /dev/mtdblock4 /floppy

Now to explain those commands.

Insmod is a command to load a module into the running kernel space. We load the two modules needed to mount an ext2 partition. Then we make an /opt directory, and mount the ext2 second partition internal card to that directory. Then we make a directory called /floppy and mount the running rootfs to it.

Now for the magic.

/tar-temp/bin/tar cf - -C /floppy . | /tar-temp/bin/tar xvf - -C /opt

*editors note.. the above command is one long line. On some screens it gets cut into two lines. I blame blogspot :-)

That command will use our new version of tar to properly copy everything over to
our card's partition. The tall bar in the middle is called a pipe. It is located
on the finger keyboard of the third tab fifth key from the right.


again root with xterm;

umount /opt
umount /floppy
chroot /mnt/initfs cal-tool --set-root-device ask:immc2
shutdown -r now

What this does is unmounts our card and rootfs. The chroot sets a little jailed system of our initfs and the rest of it adjusts the boot menu to default to the internal card's boot. Finally we reboot with the shutdown.

When the system comes back up the internal card will be selected. You can either wait the 30 seconds for the boot to start or hit the menu key, then the square key to start it right along.

Ok, a few things to be aware of running off your internal card. Sometimes because of how the card works, your system can get a little off... if you notice items missing from menus or it's just not working right, reboot to the internal flash and run this command as root from the xterm

fsck -fy /dev/mmcblk0p2

The fsck command is a file system checker, the -fy is a force run saying yes to all fixes.

These are the only other caveats I have to booting off the internal card. First, if you hook up to usb, only the external card will be usable on the pc and the internal card will not remount for use once you disconnect without a reboot. If you have to do alot of usb work, boot off the internal flash for that time. Second, sometimes the system may lock up a bit.. just pull the battery out.. boot to internal flash, run the fsck then reboot to the card and all will be well.

Enjoy

*all procedures are attempted at your own risk. I claim no responsibility if you ruin your tablet.

Props..
www.internettablettalk.com
http://maemo.org/maemowiki/HowTo_EASILY_Boot_From_MMC_card

7 comments:

mamys said...

Hi. I followed your instructions to partition and clone to my internal memory card. It works as I can now boot to my internal memory card, but I do not have any space left on my 2gb internal mem card after following the instructions. When I look at the storage details of my internal memory card, it now says total size: 160kb, In use: 1 kb and available:160kb. And zero mb available for extended virtual memory.
Do you know what could have gone wrong and how to fix this ??

Schmots said...

The problem probably happened during partioning. sfdisk is a terribly old application, but all we get on the tablet.

,356,6
,,L
,,
,,

This is the format for getting 356 megs to use for non OS space... virtual memory etc.
When running sfdisk pay close attention to the switches you use to start it.. that is the -uM part. That way you know your working in Megabytes. Also be sure that first , is there. If you would like more space for your memory card make the first number (the 356 part) bigger, just not larger than 1000 so that you still have plenty of space for lots of applications.

Schmots said...

Forgot to add that re-partioning will cause you to lose whats on your sd card and you will have to do the format and OS copy part again.

Laughing Man said...

Hi, what's the difference between using 6 to end it and C? For example you have ",356,6".

From what I've seen 6 makes it use FAT16 while C makes it use FAT32.

Schmots said...

fat 16 is more universally accepted by non windows systems. Though limited to a 2Gig partition

Bryan said...

I did this, however whenever I boot from either flash or my 4gb internal memory card I now get an error that the card is corrupt (doesn't seem to recognize the dos partition for additional storage) any advice?

ka said...

Hi i also have the same problem after doing all this i can boot either from the internal memory or the flash but it says memory card corrupted and i can't access the internal card in file manager nor the extend virtual memory option (it says there no internal memory).

Any idea how to fix this and what might be the issue?