Advanced booting
(Moved multiboot here and added info on getting kernel boot messages) |
(Undo revision 45769 by 70.135.114.247 (Talk) SPAM) |
||
(20 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | + | {{out of date}} | |
- | + | This article covers advanced booting procedures and configuration options. For the vast majority of people [[booting from a flash card]] will cover everything they need to know. | |
- | + | ||
- | + | == Multi-boot == | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | Be aware that the kernel | + | The process for setting up a multi-boot is similar to [[Booting from a flash card]]. |
+ | It's a good idea to ensure that the first partition is a FAT/data partition - this keeps things simple. | ||
+ | |||
+ | A sample partition layout on an 8Gb card might be: | ||
+ | * 2GB primary vfat data | ||
+ | * 2GB primary everyday | ||
+ | * 2GB primary debian | ||
+ | * 512MB logical test1 (diablo) | ||
+ | * 512MB logical test2 (chinook) | ||
+ | * 512MB logical test3 (diablo) | ||
+ | |||
+ | Be aware that the kernel initfs supports a limited number of partitions; this can be extended to 6 but no further. This requires editing /home/user/local/bin/initfs_flasher/initfs.bootmenu.jffs2 to add the dev nodes using mknod | ||
(eg: mknod -m600 initfs/dev/mmcblk0p5 b 254 5) | (eg: mknod -m600 initfs/dev/mmcblk0p5 b 254 5) | ||
Line 20: | Line 24: | ||
To create pristine images of Diablo/Chinook, follow the instructions for [[Modifying the root image]], but once you have the rootfs.jffs2 image extracted, you can follow the mount instructions and rsync the rootfs to the tablet. | To create pristine images of Diablo/Chinook, follow the instructions for [[Modifying the root image]], but once you have the rootfs.jffs2 image extracted, you can follow the mount instructions and rsync the rootfs to the tablet. | ||
- | I used this script (which | + | I used this script (which now works fine) |
- | < | + | <source lang="bash"> |
#!/bin/bash | #!/bin/bash | ||
Line 32: | Line 36: | ||
mkdir -p $IMAGE_DIR | mkdir -p $IMAGE_DIR | ||
- | |||
# unpack fiasco | # unpack fiasco | ||
- | $FLASHER3 -F $F_IMAGE -u | + | (cd $IMAGE_DIR; $FLASHER3 -F $F_IMAGE -u) |
# https://wiki.maemo.org/Modifying_the_root_image | # https://wiki.maemo.org/Modifying_the_root_image | ||
mknod /tmp/mtdblock0 b 31 0 | mknod /tmp/mtdblock0 b 31 0 | ||
modprobe loop | modprobe loop | ||
- | losetup /dev/loop0 rootfs.jffs2 | + | losetup /dev/loop0 $IMAGE_DIR/rootfs.jffs2 |
modprobe block2mtd | modprobe block2mtd | ||
modprobe mtdblock | modprobe mtdblock | ||
- | echo "/dev/loop0" > /sys/module/block2mtd/parameters/block2mtd | + | # Note that on a host running 2.6.27-rc2 (and probably *much* earlier), the ,128KiB sets the erase size. |
+ | echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd | ||
modprobe jffs2 | modprobe jffs2 | ||
mkdir /tmp/jffs2 | mkdir /tmp/jffs2 | ||
- | mount -t jffs2 /tmp/mtdblock0 /tmp/jffs2 | + | # mount the rootfs ro |
+ | mount -t jffs2 -o ro /tmp/mtdblock0 /tmp/jffs2 | ||
# copy files | # copy files | ||
- | ssh root@nut insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext2.ko \; mkdir /tst \; mount $PART /tst | + | ssh root@nut insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext2.ko \; mkdir /tst \; mount $PART -o noatime /tst |
- | rsync -av /tmp/jffs2/ root@nut:/tst/ | + | (cd /tmp/jffs2;tar cf - . | ssh root@nut cd /tst\;tar xf -) |
+ | # rsync may not work | ||
+ | # rsync -av /tmp/jffs2/ root@nut:/tst/ | ||
ssh root@nut umount /tst \; rmdir /tst | ssh root@nut umount /tst \; rmdir /tst | ||
Line 61: | Line 68: | ||
rm -f /tmp/mtdblock0 | rm -f /tmp/mtdblock0 | ||
rmdir /tmp/jffs2 | rmdir /tmp/jffs2 | ||
+ | rm -rf $IMAGE_DIR | ||
+ | </source> | ||
- | + | == Boot messages == | |
- | + | So if you want to see the kernel boot log or dmesg type output when you boot here's how (thanks to [[User:qwerty12|qwerty12]] for the pointers) | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | So if you want to see the kernel boot log or dmesg type output when you boot here's how (thanks to | + | |
Check you have an up-to-date initfs - does this file exist: | Check you have an up-to-date initfs - does this file exist: | ||
Line 77: | Line 80: | ||
Log into the tablet and remount initfs so you can edit it directly. (If this '''doesn't''' make you nervous then you should stop now!) | Log into the tablet and remount initfs so you can edit it directly. (If this '''doesn't''' make you nervous then you should stop now!) | ||
- | + | mount -o remount,rw /mnt/initfs | |
Now grab some kernel modules from here: | Now grab some kernel modules from here: | ||
- | + | http://fanoush.wz.cz/maemo/modules-diablo-2.6.21-200842maemo1.tar.gz | |
and copy the 4 modules you find in | and copy the 4 modules you find in | ||
- | + | ./drivers/video/console/ | |
to | to | ||
- | + | /mnt/initfs/lib/modules/`uname -r`/ | |
I extracted them on my host and did: | I extracted them on my host and did: | ||
- | + | scp drivers/video/console/* root@nut:/mnt/initfs/lib/modules/2.6.21-omap1/ | |
- | Now, for each bootmenu where you want a bootlog, edit /mnt/initfs/bootmenu. | + | Now, for each bootmenu where you want a bootlog, edit <code>/mnt/initfs/bootmenu.sh</code> and add |
- | + | softcursor bitblit font fbcon | |
- | to any | + | to any MENU_N_MODULES= lines |
- | Also add a line like this: | + | Also add a line like this (where MENU_2 will differ for you): |
- | + | MENU_2_FBMODE="auto" | |
eg: | eg: | ||
- | + | MENU_4_NAME="Diablo Test" | |
- | + | MENU_4_ID="mmc5" | |
- | + | MENU_4_DEVICE="${INT_CARD}p5" | |
- | + | MENU_4_MODULES="mbcache ext2 softcursor bitblit font fbcon" | |
- | + | MENU_4_FSTYPE="ext2" | |
- | + | MENU_4_FSOPTIONS="noatime" | |
- | + | MENU_4_FBMODE="auto" | |
- | + | [ -d "/sys/block/${INT_CARD}/${MENU_4_DEVICE}" ] || MENU_4_NAME="(${MENU_4_NAME}) N/A" | |
Finally, remount the initfs as ro and reboot. | Finally, remount the initfs as ro and reboot. | ||
- | + | mount -oremount,ro /mnt/initfs/ | |
Once your system starts, don't forget to run | Once your system starts, don't forget to run | ||
- | + | /mnt/initfs/usr/bin/fb_update_mode manual | |
or the display will run slowly. | or the display will run slowly. | ||
+ | == Initfs hacking == | ||
+ | |||
+ | Work in progress - move along | ||
+ | |||
+ | In case it isn't '''blindingly obvious''' - messing with the initfs and your tablet flash can burn you. | ||
+ | |||
+ | Note: The tools and data used whilst flashing must be stored on linux filesystems - not FAT/FAT32. | ||
+ | |||
+ | If you are brave you can edit your initfs directly if you mount initfs read-write: | ||
+ | mount -oremount,rw /mnt/initfs | ||
+ | vi $random_files | ||
+ | |||
+ | Don't forget to put it back: | ||
+ | mount -oremount,ro /mnt/initfs | ||
+ | |||
+ | This can be randomly dangerous if initfs partition is almost full (true for anything before Diablo) because your initfs can run out space whilst you are saving due to the way jffs2/flash systems work. Basically you may end in situation when even 'rm file' returns 'no space left on device'. Diablo update enlarged initfs partition from 2MB to 4MB so there is enough free space to make jffs2 garbage collector work properly (unless you fill it up again). | ||
+ | |||
+ | A safer approach (taken from fanoush's script) is: | ||
+ | cd somewhere_on_a_linux_fs | ||
+ | mkdir initfs.orig | ||
+ | mount -t jffs2 /dev/mtdblock3 initfs.orig | ||
+ | cp -a initfs.orig initfs | ||
+ | umount initfs.orig | ||
+ | # edit intifs/... | ||
+ | |||
+ | Then, once it's all edited and ready, you create a jffs2 and burn it. | ||
+ | mkfs.jffs2 -r initfs -o my_initfs.jffs2 -e 128 -l -n | ||
+ | sync | ||
+ | chroot /mnt/initfs mount -t jffs2 -o remount,ro /dev/mtdblock3 / | ||
+ | echo " *** caching old initfs to memory (for crash prevention)" | ||
+ | # block level, probably useless | ||
+ | dd if=/dev/mtdblock3 of=/dev/null bs=65536 2>/dev/null | ||
+ | # file level, read all interesting stuff (should be enough to cache dsme and bme) | ||
+ | tar cf - /mnt/initfs/usr /mnt/initfs/lib /mnt/initfs/bin /mnt/initfs/sbin >/dev/null 2>/dev/null | ||
+ | flash_eraseall -j /dev/mtd3 | ||
+ | echo " *** flashing $1 image ..." | ||
+ | nandwrite -a -p /dev/mtd3 $1 | ||
+ | Then reboot (<code>/sbin/reboot</code>) as soon as possible. dsme and bme daemons are running from (old) initfs and by reflashing underlying filesystem you just cut the branch they are sitting on. Caching done before flashing does not solve it completely. | ||
+ | |||
+ | At this point you will probably realise that grabbing fanoush's script and inserting a few extra commands to drop you to a shell etc is a lot easier than doing it all by hand. Or you may start another shell while initfs_flash script is waiting for your answer (include telnet/dropbear/bootmenu.conf?) and modify stuff in initfs_flasher/initfs/. | ||
+ | |||
+ | ===Devices=== | ||
+ | |||
+ | The standard initfs is missing some devices that may be useful on sd cards with lots of partitions so: | ||
+ | |||
+ | <pre> | ||
+ | mknod -m600 initfs/dev/mmcblk0p3 b 254 3 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk0p4 b 254 4 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk0p5 b 254 5 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk0p6 b 254 6 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk0p7 b 254 7 2>/dev/null | ||
+ | |||
+ | mknod -m600 initfs/dev/mmcblk1p3 b 254 11 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk1p4 b 254 12 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk1p5 b 254 13 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk1p6 b 254 14 2>/dev/null | ||
+ | mknod -m600 initfs/dev/mmcblk1p7 b 254 15 2>/dev/null | ||
+ | </pre> | ||
- | + | [[Category:Power users]] | |
+ | [[Category:Diablo]] |
Latest revision as of 02:46, 22 November 2011
This article is out-of-date, and needs to be updated. Please see the talk page for discussion. |
This article covers advanced booting procedures and configuration options. For the vast majority of people booting from a flash card will cover everything they need to know.
Contents |
[edit] Multi-boot
The process for setting up a multi-boot is similar to Booting from a flash card. It's a good idea to ensure that the first partition is a FAT/data partition - this keeps things simple.
A sample partition layout on an 8Gb card might be:
- 2GB primary vfat data
- 2GB primary everyday
- 2GB primary debian
- 512MB logical test1 (diablo)
- 512MB logical test2 (chinook)
- 512MB logical test3 (diablo)
Be aware that the kernel initfs supports a limited number of partitions; this can be extended to 6 but no further. This requires editing /home/user/local/bin/initfs_flasher/initfs.bootmenu.jffs2 to add the dev nodes using mknod (eg: mknod -m600 initfs/dev/mmcblk0p5 b 254 5)
When cloning, you may edit nupgrade.sh to remove the TARGET= line and then run it as follows:
TARGET=/dev/mmcblk0p5 ./nupgrade.sh 1
To create pristine images of Diablo/Chinook, follow the instructions for Modifying the root image, but once you have the rootfs.jffs2 image extracted, you can follow the mount instructions and rsync the rootfs to the tablet.
I used this script (which now works fine)
#!/bin/bash # This script connects to the tablet and sends the selected rootfs to the selected partition FLASHER3=/everything/Downloads/Hardware/nokia_n800/flasher-3.0 F_IMAGE=/everything/Downloads/Hardware/nokia_n800/RX-34_2008SE_2.2007.51-3_PR_COMBINED_MR0_ARM.bin IMAGE_DIR=chinook_fiasco PART=/dev/mmcblk0p6 mkdir -p $IMAGE_DIR # unpack fiasco (cd $IMAGE_DIR; $FLASHER3 -F $F_IMAGE -u) # https://wiki.maemo.org/Modifying_the_root_image mknod /tmp/mtdblock0 b 31 0 modprobe loop losetup /dev/loop0 $IMAGE_DIR/rootfs.jffs2 modprobe block2mtd modprobe mtdblock # Note that on a host running 2.6.27-rc2 (and probably *much* earlier), the ,128KiB sets the erase size. echo "/dev/loop0,128KiB" > /sys/module/block2mtd/parameters/block2mtd modprobe jffs2 mkdir /tmp/jffs2 # mount the rootfs ro mount -t jffs2 -o ro /tmp/mtdblock0 /tmp/jffs2 # copy files ssh root@nut insmod /mnt/initfs/lib/modules/2.6.21-omap1/ext2.ko \; mkdir /tst \; mount $PART -o noatime /tst (cd /tmp/jffs2;tar cf - . | ssh root@nut cd /tst\;tar xf -) # rsync may not work # rsync -av /tmp/jffs2/ root@nut:/tst/ ssh root@nut umount /tst \; rmdir /tst #clean up umount /tmp/jffs2 rmmod jffs2 rmmod mtdblock rmmod block2mtd losetup -d /dev/loop0 rm -f /tmp/mtdblock0 rmdir /tmp/jffs2 rm -rf $IMAGE_DIR
[edit] Boot messages
So if you want to see the kernel boot log or dmesg type output when you boot here's how (thanks to qwerty12 for the pointers)
Check you have an up-to-date initfs - does this file exist:
/mnt/initfs/usr/bin/fb_update_mode
If not then install fanoush's bootmenu/initfs.
Log into the tablet and remount initfs so you can edit it directly. (If this doesn't make you nervous then you should stop now!)
mount -o remount,rw /mnt/initfs
Now grab some kernel modules from here:
http://fanoush.wz.cz/maemo/modules-diablo-2.6.21-200842maemo1.tar.gz
and copy the 4 modules you find in
./drivers/video/console/
to
/mnt/initfs/lib/modules/`uname -r`/
I extracted them on my host and did:
scp drivers/video/console/* root@nut:/mnt/initfs/lib/modules/2.6.21-omap1/
Now, for each bootmenu where you want a bootlog, edit /mnt/initfs/bootmenu.sh
and add
softcursor bitblit font fbcon
to any MENU_N_MODULES= lines Also add a line like this (where MENU_2 will differ for you):
MENU_2_FBMODE="auto"
eg:
MENU_4_NAME="Diablo Test" MENU_4_ID="mmc5" MENU_4_DEVICE="${INT_CARD}p5" MENU_4_MODULES="mbcache ext2 softcursor bitblit font fbcon" MENU_4_FSTYPE="ext2" MENU_4_FSOPTIONS="noatime" MENU_4_FBMODE="auto" [ -d "/sys/block/${INT_CARD}/${MENU_4_DEVICE}" ] || MENU_4_NAME="(${MENU_4_NAME}) N/A"
Finally, remount the initfs as ro and reboot.
mount -oremount,ro /mnt/initfs/
Once your system starts, don't forget to run
/mnt/initfs/usr/bin/fb_update_mode manual
or the display will run slowly.
[edit] Initfs hacking
Work in progress - move along
In case it isn't blindingly obvious - messing with the initfs and your tablet flash can burn you.
Note: The tools and data used whilst flashing must be stored on linux filesystems - not FAT/FAT32.
If you are brave you can edit your initfs directly if you mount initfs read-write:
mount -oremount,rw /mnt/initfs vi $random_files
Don't forget to put it back:
mount -oremount,ro /mnt/initfs
This can be randomly dangerous if initfs partition is almost full (true for anything before Diablo) because your initfs can run out space whilst you are saving due to the way jffs2/flash systems work. Basically you may end in situation when even 'rm file' returns 'no space left on device'. Diablo update enlarged initfs partition from 2MB to 4MB so there is enough free space to make jffs2 garbage collector work properly (unless you fill it up again).
A safer approach (taken from fanoush's script) is:
cd somewhere_on_a_linux_fs mkdir initfs.orig mount -t jffs2 /dev/mtdblock3 initfs.orig cp -a initfs.orig initfs umount initfs.orig # edit intifs/...
Then, once it's all edited and ready, you create a jffs2 and burn it.
mkfs.jffs2 -r initfs -o my_initfs.jffs2 -e 128 -l -n sync chroot /mnt/initfs mount -t jffs2 -o remount,ro /dev/mtdblock3 / echo " *** caching old initfs to memory (for crash prevention)" # block level, probably useless dd if=/dev/mtdblock3 of=/dev/null bs=65536 2>/dev/null # file level, read all interesting stuff (should be enough to cache dsme and bme) tar cf - /mnt/initfs/usr /mnt/initfs/lib /mnt/initfs/bin /mnt/initfs/sbin >/dev/null 2>/dev/null flash_eraseall -j /dev/mtd3 echo " *** flashing $1 image ..." nandwrite -a -p /dev/mtd3 $1
Then reboot (/sbin/reboot
) as soon as possible. dsme and bme daemons are running from (old) initfs and by reflashing underlying filesystem you just cut the branch they are sitting on. Caching done before flashing does not solve it completely.
At this point you will probably realise that grabbing fanoush's script and inserting a few extra commands to drop you to a shell etc is a lot easier than doing it all by hand. Or you may start another shell while initfs_flash script is waiting for your answer (include telnet/dropbear/bootmenu.conf?) and modify stuff in initfs_flasher/initfs/.
[edit] Devices
The standard initfs is missing some devices that may be useful on sd cards with lots of partitions so:
mknod -m600 initfs/dev/mmcblk0p3 b 254 3 2>/dev/null mknod -m600 initfs/dev/mmcblk0p4 b 254 4 2>/dev/null mknod -m600 initfs/dev/mmcblk0p5 b 254 5 2>/dev/null mknod -m600 initfs/dev/mmcblk0p6 b 254 6 2>/dev/null mknod -m600 initfs/dev/mmcblk0p7 b 254 7 2>/dev/null mknod -m600 initfs/dev/mmcblk1p3 b 254 11 2>/dev/null mknod -m600 initfs/dev/mmcblk1p4 b 254 12 2>/dev/null mknod -m600 initfs/dev/mmcblk1p5 b 254 13 2>/dev/null mknod -m600 initfs/dev/mmcblk1p6 b 254 14 2>/dev/null mknod -m600 initfs/dev/mmcblk1p7 b 254 15 2>/dev/null
- This page was last modified on 22 November 2011, at 02:46.
- This page has been accessed 75,773 times.