From: <bob...@us...> - 2006-08-09 09:09:42
|
Revision: 537 Author: bobofdoom Date: 2006-08-09 02:09:27 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/hackndev/?rev=537&view=rev Log Message: ----------- Initial import of Cris' initramfs scripts. Added Paths: ----------- linux4palm/initramfs/ linux4palm/initramfs/Makefile linux4palm/initramfs/files/ linux4palm/initramfs/files/etc/ linux4palm/initramfs/files/etc/modules.initrd linux4palm/initramfs/files/init linux4palm/initramfs/svn-commit.tmp Added: linux4palm/initramfs/Makefile =================================================================== --- linux4palm/initramfs/Makefile (rev 0) +++ linux4palm/initramfs/Makefile 2006-08-09 09:09:27 UTC (rev 537) @@ -0,0 +1,3 @@ +# TODO; +# Build an initramfs image from busybox source. +# Using klibc if possible for nice smallness. Added: linux4palm/initramfs/files/etc/modules.initrd =================================================================== --- linux4palm/initramfs/files/etc/modules.initrd (rev 0) +++ linux4palm/initramfs/files/etc/modules.initrd 2006-08-09 09:09:27 UTC (rev 537) @@ -0,0 +1,3 @@ +fat.ko +vfat.ko +loop.ko Property changes on: linux4palm/initramfs/files/etc/modules.initrd ___________________________________________________________________ Name: svn:executable + Added: linux4palm/initramfs/files/init =================================================================== --- linux4palm/initramfs/files/init (rev 0) +++ linux4palm/initramfs/files/init 2006-08-09 09:09:27 UTC (rev 537) @@ -0,0 +1,132 @@ +#!/bin/sh +# $Id: $ +# authors: Cristiano P. +# + +# TODO: echo only if VERBOSE +# TODO: check the whole thing ... + +# defaults: +VERBOSE=true +FILES_DEV=/dev/mmcblk0p1 +FILES_MNT=/media/mmc1 +ROOT_DEV=$FILES_MNT/opie-image-v0.8.4-rc3-palmtx.rootfs.ext2 +#ROOT_DEV=/dev/mmcblk0p5 +#SWAP_DEV=$CARD_MNT/swap.fs +SWAP_DEV=/dev/mmcblk0p7 + +MODULES_DIR="/lib/modules" +POST_MODULES_SCRIPT="" + +echo initram init started + + +if [ -f /etc/modules.initrd ]; then + echo loading initial modules + cat /etc/modules.initrd | while read module; do + echo loading module: $module + /sbin/insmod $MODULES_DIR/$module > /dev/null + done +fi + +echo mounting sysfs +#mount -n -t sysfs none /sys +mount -n -t sysfs sys /sys >/dev/null 2>&1 || mount -t sysfs sys /sys + +echo mounting proc filesystem +#mount -n -t proc /proc +mount -n -t proc none /proc >/dev/null 2>&1 || mount -t proc none /proc + +if [ -b $FILES_DEV ]; then + echo -n "linux.boot.cfg on $FILES_DEV: " + /bin/mount -n -t vfat -o rw $FILES_DEV $FILES_MNT + /bin/sleep 1 + # todo: check parameters/files? + if [ -f $FILES_MNT/linux.boot.cfg ]; then + echo found. + . $FILES_MNT/linux.boot.cfg + + if [ -f $FILES_MNT/modules.initrd ]; then + echo loading additional modules now: + cat $FILES_MNT/modules.initrd | while read module; do + loading module: $module + /sbin/insmod $MODULES_DIR/$module > /dev/null + done + fi + + else + echo not found. + fi +else + echo fat16 partition not found. +fi + + +# this script could be used to update the rootfs before booting familiar (new modules, scripts, config, ...) +echo -n "post_module script: " +if [ -n "$POST_MODULES_SCRIPT" ]; then + if [ -f "$POST_MODULES_SCRIPT" ]; then + echo found $POST_MODULES_SCRIPT . + $POST_MODULES_SCRIPT + fi +else + echo not found. +fi + +# probably swap should/can be enabled by familiar +# is it the right place to mount swap? +if [ -n "$SWAP_DEV" ]; then + echo -n "mount swap at $SWAP_DEV: " + + if [ -f $SWAP_DEV -o -b $SWAP_DEV ]; then + /sbin/swapon $SWAP_DEV > /dev/null 2>&1 + echo done. + else + echo not found. + fi +fi + + +echo attempting to mount rootfs [$ROOT_DEV] + +ROOT_MOUNTED=true +UMOUNT_MMC=true + +if [ -f $ROOT_DEV ]; then + #echo 0x702 > /proc/sys/kernel/real-root-dev + mount -n $ROOT_DEV /newroot -o rw loop 2>/dev/null + [ $? ] || ROOT_MOUNTED=false + UMOUNT_MMC=false +elif [ -b $ROOT_DEV ]; then + mount -n $ROOT_DEV /newroot -o rw 2>/dev/null + [ $? ] || ROOT_MOUNTED=false +else + ROOT_MOUNTED=false +fi + +# probably this is not anymore needed here ... umount and free memory +if [ $UMOUNT_MMC = "true" ]; then + umount $FILES_MNT +fi + +# TODO: should initial /dev (/oldroot/dev) be unmounted after init by GPE? +if [ $ROOT_MOUNTED = "true" ]; then + echo root fs mounted + + # force umount sys and proc (otherwise we'll find them mounted twice) + umount -l /sys + umount -l /proc + + # method 2: use switch_root (needs initramfs) + exec /sbin/switch_root -c /dev/console /newroot /sbin/init 5 + + echo "* * * chroot failed! * * *" +else + echo could not mount root fs: init failed! + echo please, reset, check your configuration and retry. + sleep 100000 +fi + +# TODO: run ezhikov's keyshell here? +exec /bin/sh + Property changes on: linux4palm/initramfs/files/init ___________________________________________________________________ Name: svn:executable + Added: linux4palm/initramfs/svn-commit.tmp =================================================================== --- linux4palm/initramfs/svn-commit.tmp (rev 0) +++ linux4palm/initramfs/svn-commit.tmp 2006-08-09 09:09:27 UTC (rev 537) @@ -0,0 +1,4 @@ +Initial import of Cris' initramfs scripts. +--This line, and those below, will be ignored-- + +A . This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |