#!/bin/sh # Netbook LX initial ramdisk boot script panic() { echo $1 *ABORTING* - Emergency shell exec /bin/sh exit } #linux 2.4 specific linux24_specific() { #add keyboard modules /sbin/modprobe i2c > /dev/null /sbin/modprobe i2ckbd > /dev/null #start pcmcia stuff /sbin/cardmgr -o -q } #linux 2.6 specific linux26_specific() { # temporary measure, anounce ourselves echo "Running Linux 2.6 System" echo "System is starting Kernel 2.6" > /dev/tty0 # we seem to need to run cardmgr twice? /sbin/cardmgr -o -q # /sbin/cardmgr -o -q } #mount and check # mount_n_check mount_n_check() { MOUNTOPTS=$1 shift DEVICE=$1 shift MOUNTPT=$1 shift # TODO: check ${MOUNTPT} isnt in use # if ( cat /proc/mounts | cut -d " " -f 2 | grep -q "^${MOUNTPT}\$" );then echo it is; fi # damm - pity we dont have grep mount ${MOUNTOPTS} ${DEVICE} ${MOUNTPT} MNTERR=$? if [ ${MNTERR} -eq 0 ]; then #ok it mounted, is there anything of interest here? for FILE in $*; do if [ ! -x "${MOUNTPT}/${FILE}" ]; then # no file? need to unmount and return umount ${MOUNTPT} return 1 fi done return 0 fi return ${MNTERR} } #proc filesystem mount proc /proc -t proc if [ $? -ne 0 ];then panic "Unable to mount proc filesystem system" fi # work out what sort of system we're running on LINUXVER=`uname -r | cut -d. -f1-2` if [ "${LINUXVER}" = "2.6" ]; then linux26_specific ${LINUXVER} else linux24_specific ${LINUXVER} fi # check for NBLXLoad.sh to use to bootstrap/upgrade system mount_n_check "-o ro" /dev/hda1 /rootfs NBLXLoad.sh if [ $? -eq 0 ]; then # ok it mounted and file is there /rootfs/NBLXLoad.sh umount /rootfs fi # mount root filesystem # try the internal nand first mount_n_check "-o ro" /dev/hda2 /rootfs #/bin/sh /sbin/init if [ $? -ne 0 ]; then # try second partition on a cf card second mount_n_check "-t jffs2 -o ro" /dev/mtdblock/0 /rootfs /bin/sh /sbin/init if [ $? -ne 0 ]; then panic "Unable to mount root filesystem" fi fi #start the real init if [ -d /rootfs/initrd ]; then echo Pivoting filesystem umount /proc cd /rootfs /sbin/pivot_root . initrd if [ $? -ne 0 ];then panic "Unable to pivot to root filesystem" fi exec /usr/sbin/chroot . /sbin/init dev/console 2>&1 panic "chroot failed" else panic "Initrd mount point missing in root filesystem" fi