diff options
author | John Bowler <jbowler@nslu2-linux.org> | 2005-08-14 18:00:44 +0000 |
---|---|---|
committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2005-08-14 18:00:44 +0000 |
commit | 116dddad4ec038b7d4322f8201556e6cf420fb96 (patch) | |
tree | 6b63fde6284678a936958ac42f0743a8e1869e70 /packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc | |
parent | aa37baae309e595282a53af6cdfe7a5a77eb530a (diff) | |
parent | 856f8e9dbe8ab445ecde0e10c86bcc9b0bda00f8 (diff) |
merge of a43a3081d043237ce284af591c69b35171e746be
and b91f743ce475bca1b138c7fd63260e83a34f53c2
Diffstat (limited to 'packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc')
-rwxr-xr-x | packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc new file mode 100755 index 0000000000..cc53d447c3 --- /dev/null +++ b/packages/nslu2-binary-only/unslung-rootfs-2.3r63/linuxrc @@ -0,0 +1,70 @@ +#!/bin/sh + +# **** DO NOT EVEN THINK OF EDITING OR REMOVING THIS FILE **** +# **** UNLESS YOU REALLY KNOW *EXACTLY* WHAT YOU ARE DOING. **** + + +# Perform prepatory tasks, and determine whether an alternate rootfs is viable. + +/bin/mount -t proc proc /proc + +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 + [ -f /proc/hdd_sdb ] && cnt=0 + [ -f /proc/hdd_sda ] && cnt=0 + cnt=`expr $cnt - 1` +done +echo + +sleep 5 + +mounted= + +for prefroot in sdb1 sda1 ; do + if [ -z "$mounted" ] ; then + if /bin/mount -rt ext3 /dev/$prefroot /mnt ; then + if [ -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 +done + +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. + +if [ -n "$mounted" ] ; then + + cd $mounted + + /bin/echo "Pivoting to external rootfs ..." + /sbin/pivot_root . initrd + + exec /usr/sbin/chroot . /bin/init < /dev/console 1> /dev/console 2> /dev/console + +else + + exec /bin/init + +fi + +/bin/echo "Can't pivot to external rootfs, using ramdisk ..." +exec /bin/init + +# Last-resort fall-back - this should never be reached. +/bin/sh |