Author Topic: Dual boot setup  (Read 28740 times)

derekp

  • Full Member
  • ***
  • Posts: 154
    • View Profile
Dual boot setup
« on: February 04, 2004, 11:55:57 pm »
I\'ve been playing around with a dual-boot setup for my 5500 that allows me to keep a Sharp-based rom installed, yet lets me boot up an alternate distribution, such as OpenZaurus, from my SD card.  If anyone\'s interested, I can put together a howto article, and some scripts to automate rebuilding your Sharp image to support this.

The basic modifications to the Sharp rom is:
(this is pseudo code from memory, I haven\'t had time to put together a cleaned up version yet)
1) Move /sbin/init to /sbin/orig/init
2) Create a shell script in the place of /sbin/init that does the following:
  - insmod the mmc/sd driver
  - mount ramfs filesystem on /dev, and populate it as necissary
  - mount sd card
  - if [ -f /mnt/card/init.card ]
  - then
  -     cp /nt/card/init.card /dev/.
  -     umount /mnt/card
  -     exec /mnt/card/init.card
  - else
         umount /mnt/card
         rmmod mmc/sd module
  -      exec /sbin/orig/init $@
  - fi

3) Copy root filesystem contents of desired rom image to the SD card
4) Create an init.card script on the SD card that does:
  - mv /dev/mmcda1 /dev/mmcsd1   (needed so that the contents of the SD card doesn\'t appear as any type of external storage to opie apps, otherwise it can cause problems with anything that scan all files on mounted media)
  - mount -oasync,noatime /dev/mmcsd1 /mnt/card
  - pivot_root /mnt/card
  - exec /sbin/init

The various \"exec\" lines in the fake /sbin/init script on the rom and in the init.card are needed so that the final real init that ends up running is still process id 1.  Also, a couple of adjustments were needed to the OZ rc scripts to accomidate the differences between the OZ kernel and the Sharp one.  Also, you need to compile install on your sharp-derived rom a copy of pivot_root,  you can\'t use the one from OZ as it is linked against a newer version of ld-linux.

I\'ve been using this for a while now, and so far very few problems have popped up.  With some cheaper brands of SD cards, you might have problems with suspending due to bugs in the Sharp SD driver, but my Lexar card seems to due ok.  Also, I am currently getting a lockup sometimes if I suspend while in the docking cradle.  I think this is fixable by having an apm script that turns off the usb port during suspend.

Let me know if anyone wants me to put together some scripts that will automate rebuilding a Sharp (or TKC) rom image to support the above.  I may even get the scripts to work on the Z itself instead of having to build it on another Linux workstation.  Personally, I think this is a great way to try out OZ, and other roms.  Also makes it much more functional, as you end up with a much larger root filesytem (potentially 512 meg instead of 16 meg that you get within the Z\'s flash).

--derek

Anonymous

  • Guest
Dual boot setup
« Reply #1 on: February 05, 2004, 12:00:32 am »
Do you realize this feature makes the Zaurus the most powerful PDA ever!  Good work Derek!  A script would be most welcome!

derekp

  • Full Member
  • ***
  • Posts: 154
    • View Profile
Dual boot setup
« Reply #2 on: February 05, 2004, 12:15:30 am »
There are a few external programs my script will require.  I will go ahead and upload a package containing the necissary items, but would rather point to existing ones if they are available.
1) Zaurus version of mkcramfs.  I haven\'t found it anywhere, so I compiled it myself along with a bunch of other Linux utils
2) pivot_root that works on Sharp rom.  You can\'t call the OZ version from sharp, even if you set LD_LIBRARY_PATH, since OZ uses a newer version of ld-linux.so
3) A copy of the OZ 3.3.5 image as a tar.gz file.  Currently, the only way I know to get it is to load a mtdblock and mtdram driver on a Linux workstation, dd the image to the emulated mtdblock device, them mount it an tar it up.  I can upload the copy I made, but would rather point to an official version in my instructions.
With the above three available, I think everything can be done on the Zaurus, assuming you have enough free space available on a CF card.

Also note, that this would still remain an advanced install procedure, the user would need to be proficient at the Linux command line to get it to work (I\'ll do the best I can to make it easy).

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
Dual boot setup
« Reply #3 on: February 05, 2004, 02:13:41 am »
Wow, looks like you just saved me days of pain and frustration

I was palnning on trying something like this, but you gone and done it already - YAY!

Please let us know where the how-to is/will be posted. I\'m dying to try this out on my C760 - will make testing new roms a much more pleasant task if I can just remove a SD card and reboot to my stanard system.

thanks

Stu
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

jerrybme

  • Hero Member
  • *****
  • Posts: 639
    • View Profile
    • http://
Dual boot setup
« Reply #4 on: March 08, 2004, 09:19:54 am »
Quote
There are a few external programs my script will require.  I will go ahead and upload a package containing the necissary items, but would rather point to existing ones if they are available.

Derek:
Did you post this package? There was a prep-home SD package in the ZUG downloads, but in reading the description it seems to slightly different from what you describe in this thread. I\'m interested in trying this with a Sharp based ROM in internal memory and booting to pdaXrom on SD. The latest Cacko Qt ROM, allows access to terminal before QT rom loads which I\'m thinking may be helpful in this process.
Thanks,
Jerry
SL-C3100
Angstrom-GPE
Lexar SD 1 GB
PQI 2GB CF
Ambicom WL1100 CF

Anonymous

  • Guest
Dual boot setup
« Reply #5 on: March 08, 2004, 10:38:56 am »
does this \"pivot_root\" change the kernel or not? I was going to try the iptables. I think something have to be compiled into the kernel, like OZ did, not just the modules.

So, if I have a sharp rom and pivot_root to OZ, can I use the iptables?

Thanks?

Stubear

  • Hero Member
  • *****
  • Posts: 1164
    • View Profile
    • http://
Dual boot setup
« Reply #6 on: March 08, 2004, 04:50:04 pm »
Nope, pivot_root just changes where / is.

AFAIK there is NO way to change kernels on the fly - you must reboot to change to another kernel
SL-C1000, Hand converted to English with Japanese Input
Running X apps via X/Qt
iRiver USB host cable; Diatec P-Cord usb power cable (extendable); Acro's Reel Cable USB (A to A, B, Mini-B,  & Mini-B 8pin); GreenHouse 1Gb PicoDrive+; 2x256Mb Hagiwara SD cards; 128Mb Transcend CF card; 512Mb PQI CF card; AmbiCom WL1100C-CF 11B WLAN card

derekp

  • Full Member
  • ***
  • Posts: 154
    • View Profile
Dual boot setup
« Reply #7 on: March 09, 2004, 04:05:48 pm »
I\'m just putting the finishing touches on the whole package.  Will need to go through several more hours of testing with different roms and configurations, the last thing I want is for it to brick someones Zaurus (although the worst that should happen is you\'d have to re-flash from a known good rom).
Currently recovering from a week of on-call.  I should have something posted up by Thursday.

--derek

Joshp

  • Sr. Member
  • ****
  • Posts: 265
    • View Profile
    • http://
Dual boot setup
« Reply #8 on: March 09, 2004, 04:12:25 pm »
Hey Derek,
Have you tried running any other rom off the sd.

JP

jerrybme

  • Hero Member
  • *****
  • Posts: 639
    • View Profile
    • http://
Dual boot setup
« Reply #9 on: March 09, 2004, 04:24:34 pm »
Quote
I\'m just putting the finishing touches on the whole package.  Will need to go through several more hours of testing with different roms and configurations, the last thing I want is for it to brick someones Zaurus (although the worst that should happen is you\'d have to re-flash from a known good rom).
Currently recovering from a week of on-call.  I should have something posted up by Thursday.

--derek
Great news, I look forward to checking it out, thanks for sharing your work
SL-C3100
Angstrom-GPE
Lexar SD 1 GB
PQI 2GB CF
Ambicom WL1100 CF

maslovsky

  • Hero Member
  • *****
  • Posts: 1426
    • View Profile
    • http://my-zaurus.narod.ru
Dual boot setup
« Reply #10 on: March 10, 2004, 02:39:47 am »
Yes, this is great. I\'ve been thinking of flashing my 5500 with OZ (now that I have 750 to play with), but having both ROMs will be even nicer.

derekp

  • Full Member
  • ***
  • Posts: 154
    • View Profile
Dual boot setup
« Reply #11 on: March 10, 2004, 09:47:53 pm »
Ok, here\'s a quick status update.
I\'ve got the rom modification script wrote, and got mkcramfs compiled so everything can be run from the zaurus (no need to have access to a linux pc).  It will read your existing (sharp, tkc) rom image, and create a new one with a modified /sbin/init, /root/etc/rc.d/rc.sysinit, and a few other utilities & scripts added.  It then deposits this new initrd.bin file on your CF card ready for you to flash.  The problem I ran into in testing is that mkcramfs would segfault and cause some minor havoc about 1 in 4 tests.  It appears to run ok if qtopia is shut down.  But this isn\'t an acceptable track record (to me at least).  I\'ve identified where the problem is: mkcramfs creates a large annonymous mmap which exhausts memory, even with a fairly big swap file.  So I\'m modifying mkcramfs to take a commandline option so that it could use a specified temp file as backing for this particular mmap call.  This should not only eliminate this segfault error, but also eliminate the need to create a temporary swap file on the CF card.
A second package that I\'ve just started on will take an existing OpenZaurus initrd.bin file, and extract the contents to your SD card.  This required me to compile the mtdram and jffs2 kernel modules.  Will need to pakage both these scripts and associated tools into ipk files, then reflash my Z with a standard Sharp kernel and do a couple more dry run tests.
I will post the results to this thread as an attachment if everything checks out tomorrow.  If not, then it will definately be ready by next wednesday (I have another commitment for over the weekend).

Anonymous

  • Guest
Dual boot setup
« Reply #12 on: March 10, 2004, 10:58:08 pm »
Awesome derek!

jerrybme

  • Hero Member
  • *****
  • Posts: 639
    • View Profile
    • http://
Dual boot setup
« Reply #13 on: March 19, 2004, 04:09:47 pm »
Quote
Ok, here\'s a quick status update...

How\'s it going with this project?
Cheers,

Jerry
SL-C3100
Angstrom-GPE
Lexar SD 1 GB
PQI 2GB CF
Ambicom WL1100 CF

derekp

  • Full Member
  • ***
  • Posts: 154
    • View Profile
Dual boot setup
« Reply #14 on: March 22, 2004, 05:06:41 pm »
I\'ve finally got the dualboot scripts tweaked enough for a first release.
I highly recommend grabbing the async io kernel also.  Otherwise, the
SD card is to painfully slow to use as your main root filesystem.


Dualboot setup quick instructions

I. Backup your current stuff.

II.  Install modrom-dualboot.ipk.  Then run /usr/local/bin/modrom-dualboot.sh
This requires that you have a 128meg CF card inserted.  It will read your
currently installed rom image, and create a new initrd.bin file, deposit
it on your CF card.  Then use the normal rom flashing technique to reflash
your Zaurus with this new rom.  I have tested this on a freshly installed
Sharp 3.10 rom image, it should also work for v3.13, and for tkcrom 1.0.

The modifications made to the rom are:
1) new /sbin/init -- this is now a shell script that will check for an
alternate system on your SD card on bootup.  If no alternate distribution
exists on your SD card, the Zaurus will continue to bootup normally off the
internal rom image.
2) modified /root/etc/rc.d/rc.sysinit script.  This modification has nothing
to do with dualboot, it is there to support optional /home on SD, same as
with tkcrom 2.0-alpha3.  See prep-home-sd.sh documentation for details on
this.

III.  Once you have the dual-boot rom created and flashed, test it out
to see if it is working ok (i.e., reboot a time or two, reset, etc.)
Then, install oz2sd.ipk.  Place the OpenZaurus 3.3.5 initrd.bin file on
your CF card, and then run:
   /usr/local/bin/oz2sd.sh -i /mnt/cf/initrd_oz_3.3.5.bin
This will:
  * insmod mtdram and jffs2 kernel modules
  * copy oz\'s initrd to the mtdram test device (should be /dev/mtdblock3)
  * tar up oz, creating /mnt/cf/oz.tar.gz
  * unload the modules to free up memory
  * ext2 format your SD card, and extract oz to it.
  * create a file on your SD root, called \"init.card\".  This is what gets
    called by the modified /sbin/init in the dualboot rom.
  * patches up a few oz files to make it run better from your SD card

There are a few command line options available for oz2sd.sh, you should be
able to figure them out from the source.  They mostly affect default
temp file locations and such.  Also, it creates a temporary swapfile in
/home/swap.tmp1, 16 meg.  This is needed because the mtdram module (used
to help extract the jffs2 oz image) takes up so much memory.
You may also want to run oz2sd.sh without qpe running (when booting the
zaurus, hit \"/\" at the \"Wait..5..4..3..2..1\" countdown, and log in as root).
I\'ve had a couple out-of-memory conditions happen when running it.

In short, here\'s a quick recap of the quick instructions:
1) Flash the async io kernel located in the downloads section (optional,
but highly desirable)
2) Install modrom-dualboot_arm.ipk, insert a 128meg CF card, and run modrom-dual
boot.sh
3) Reflash rom with new initrd.bin file (assuming no errors -- size should be
about 14 meg).
4) Reboot, install oz2sd_arm.ipk, put initrd_oz_3.3.5.bin on your CF card,
stop the gui (or boot without it), and run
oz2sd.sh -i /mnt/cf/initrd_oz_3.3.5.bin (with an SD card inserted)
5) Reboot with the SD card inserted.  To boot into your normal Sharp rom,
boot without the SD card.

Again, this should work with Sharp rom 3.10, 3.13, and tkcrom 1.0, possibly
other sharp-style roms.  Also, when before you flash the modified rom image,
do a quick sanity check (is it about 14 megs?  were there any errors? etc.)
I will be putting together a bit more comprehensive documentation, and an
explaination of what all is changed, but this should get you going for now.

Have fun...
--derek