diff options
author | Rod Whitby <rod@whitby.id.au> | 2006-04-11 06:32:39 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2006-04-11 06:32:39 +0000 |
commit | 4cbd322d0f3861f9186f104d126844c5442f9a25 (patch) | |
tree | 3b537e6ded2db48e3703581d5f52124da355d357 /packages/nslu2-binary-only/unslung-rootfs/linuxrc | |
parent | 3b3f3f4da734d0f86331f1469c6c391dbda1368c (diff) |
unslung-kernel, unslung-image: Now that 6.8-beta is released, moved mainline to R63 and dropped R29 (people can get it from SVN if they want to build old versions)
Diffstat (limited to 'packages/nslu2-binary-only/unslung-rootfs/linuxrc')
-rwxr-xr-x | packages/nslu2-binary-only/unslung-rootfs/linuxrc | 134 |
1 files changed, 36 insertions, 98 deletions
diff --git a/packages/nslu2-binary-only/unslung-rootfs/linuxrc b/packages/nslu2-binary-only/unslung-rootfs/linuxrc index af694bc68d..d8a0e5d06c 100755 --- a/packages/nslu2-binary-only/unslung-rootfs/linuxrc +++ b/packages/nslu2-binary-only/unslung-rootfs/linuxrc @@ -4,101 +4,46 @@ # **** UNLESS YOU REALLY KNOW *EXACTLY* WHAT YOU ARE DOING. **** -# Determine the desired rootfs based on user flag files. - -if [ -f /.sda1root ] ; then - /bin/echo "Preferred root device is /dev/sda1 (disk 1)" - mounted=/mnt - prefroot=sda1 -elif [ -f /.sda2root ] ; then - /bin/echo "Preferred root device is /dev/sda2 (disk 1)" - mounted=/mnt - prefroot=sda2 -elif [ -f /.sdb1root ] ; then - /bin/echo "Preferred root device is /dev/sdb1 (disk 2)" - mounted=/mnt - prefroot=sdb1 -elif [ -f /.sdb2root ] ; then - /bin/echo "Preferred root device is /dev/sdb2 (disk 2)" - mounted=/mnt - prefroot=sdb2 -elif [ -f /.nfsroot ] ; then - /bin/echo "Preferred root device is NFS" - mounted=/mnt - prefroot=nfsroot -else - /bin/echo "Preferred root device is jffs2" - mounted= - prefroot=jffs2 -fi - - -# Perform prepatory tasks, and determine whether the desired rootfs is viable. +# Perform prepatory tasks, and determine whether an alternate rootfs is viable. /bin/mount -t proc proc /proc -if [ $prefroot = "sda1" -o $prefroot = "sda2" -o $prefroot = "sdb1" -o $prefroot = "sdb2" ] ; then - /bin/echo "Sleeping while waiting for disk..." - cnt=20 - while [ $cnt -gt 0 ] ; do - echo -ne "\r$cnt " - sleep 1 - [ $prefroot = "sda1" ] && [ -f /proc/hd_conn ] && cnt=0 - [ $prefroot = "sda2" ] && [ -f /proc/hd_conn ] && cnt=0 - [ $prefroot = "sdb1" ] && [ -f /proc/hd2_conn ] && cnt=0 - [ $prefroot = "sdb2" ] && [ -f /proc/hd2_conn ] && cnt=0 - cnt=`expr $cnt - 1` - done - echo - /bin/mount -rt ext3 /dev/$prefroot /mnt - if [ -L /mnt/sbin/init -o -x /mnt/sbin/init -o \ - -L /mnt/bin/init -o -x /mnt/bin/init ] ; then - /bin/echo "Root filesystem will be mounted from /dev/$prefroot ..." - else - /bin/umount /mnt - /bin/echo "Can't find valid rootfs on /dev/$prefroot, using jffs2 ..." - mounted= - prefroot=jffs2 +echo "1" > /proc/sys/kernel/panic + +/bin/echo "Sleeping while waiting for disk..." +cnt=20 +while [ $cnt -gt 0 ] ; do + echo -ne "\r$cnt " + sleep 1 + [ -e /.sda1root -a -f /proc/hdd_sda ] && cnt=0 + [ -e /.sdb1root -a -f /proc/hdd_sdb ] && cnt=0 + cnt=`expr $cnt - 1` +done +echo + +sleep 5 + +mounted= + +for prefroot in sda1 sdb1 ; do + if [ -z "$mounted" -a -e /.${prefroot}root ] ; then + if /bin/mount -rt ext3 /dev/$prefroot /mnt ; then + if [ -e /mnt/.${prefroot}root -a -x /mnt/bin/init ] ; then + /bin/echo "Root filesystem will be mounted from /dev/$prefroot ..." + mounted=/mnt + else + /bin/umount /mnt + /bin/echo "Can't find valid rootfs on /dev/$prefroot ..." + fi fi -fi - -if [ $prefroot = "nfsroot" ] ; then - - sysconflen=`/bin/dd if=/dev/mtd1 bs=4 count=1 2>/dev/null | /usr/bin/hexdump -n 6 -e '"%02d"'` - ipaddr=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep ip_addr | sed -e s/ip_addr=//` - netmask=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep netmask | sed -e s/netmask=//` - gateway=`/bin/dd if=/dev/mtd1 bs=1 count=$sysconflen skip=4 2>/dev/null | grep gateway | sed -e s/gateway=//` - - /sbin/insmod ixp400 - /sbin/insmod ixp425_eth - /sbin/ifconfig ixp0 up $ipaddr netmask $netmask - /sbin/route add default gw $gateway - - /sbin/ifconfig lo up 127.0.0.1 + fi +done - # The nfsrootloc and nfsrootopts vars can be overridden here. - . /.nfsroot - - /bin/mount $nfsrootopts $nfsrootloc /mnt - - if [ -L /mnt/sbin/init -o -x /mnt/sbin/init -o \ - -L /mnt/bin/init -o -x /mnt/bin/init ] ; then - /bin/echo "Root filesystem will be mounted from an NFS root ..." - mounted=/mnt - else - /bin/umount /mnt - /bin/echo "Can't find valid NFS rootfs, using jffs2 ..." - mounted= - prefroot=jffs2 - fi -fi - -if [ $prefroot = "jffs2" ] ; then - /bin/echo "Root filesystem will be mounted from /dev/mtdblock4 ..." - mounted= +if [ -z "$mounted" ] ; then + /bin/echo "Can't find valid rootfs, using ramdisk ..." + mounted= fi - /bin/umount /proc # Pivot to the desired rootfs and run the initial executable. @@ -107,17 +52,10 @@ if [ -n "$mounted" ] ; then cd $mounted - if [ -x ./sbin/init -o -L ./sbin/init ] ; then - runboot=/sbin/init - elif [ -x ./bin/init -o -L ./bin/init ] ; then - runboot=/bin/init - else - runboot=/bin/sh - fi - + /bin/echo "Pivoting to external rootfs ..." /sbin/pivot_root . initrd - exec /usr/sbin/chroot . $runboot < /dev/console 1> /dev/console 2> /dev/console + exec /usr/sbin/chroot . /bin/init < /dev/console 1> /dev/console 2> /dev/console else @@ -125,7 +63,7 @@ else fi -/bin/echo "Can't chroot to $prefroot, using jffs2 ..." +/bin/echo "Can't pivot to external rootfs, using ramdisk ..." exec /bin/init # Last-resort fall-back - this should never be reached. |