as the subject implies, I'm using a ts-7260 and a 2.6.21-ts kernel.
what I want to do is boot from flash and (if there's an SD card present)
move the root to the SD card.
(for several reasons, I do not want to boot directly to the SD card.
e.g. if the SD card is corrupted or missing I want to be able to run
with reduced functionality from the flash card.)
what I'm doing now is booting with root=/dev/mtdblock1 and
init=/init.sdroot .
(shown below). I built a minimal file system for the on board flash
starting
with busybox and adding in a few other things. this mostly works,
but I get
a few random error messages, and it seems that devfs isn't quite right.
I'm thinking that surely there is a simpler and/or cleaner way to do this.
any ideas?
the crux of the problem seems to be that in order to mount the SD card
(and move the root to it) I have to first load the driver. but unless
devfs is running the /dev/tssdcard* device files don't get created.
(if I use mknod to create /dev files with the same major/minor numbers
they don't work, so I'm thinking that the device numbers are dynamically
assigned) and in order to run things like fdisk (to check for the
presence
of a linux file system on the SD card) and fsck and a few other things to
make a robust init.sdroot script, the boot process needs to be fairly far
along, which then creates more difficulty in moving the root without
leaving
loose ends lying around.
init.sdroot looks like this:
----------------------------------------------------------------------------
#!/bin/sh
#
# alternate 'init' program which tries to load the secure digital
# card driver and move root to that device.
# failing that, it runs /etc/init on the normal root file system
# (e.g. the one passed to the kernel on the command-line)
#
fail ()
{
echo ''
echo '@@@' "$@"
echo ''
echo '@@@ init.sdboot failed - dumping you into a shell'
echo '@@@ hit ^D to run /sbin/init on the default root'
echo ''
/bin/sh -
exec /sbin/init
}
echo "init.sdroot v1.0"
#
# run (don't source!) some of the absolutely essential stuff from
/etc/rcS.d
#
# mount /proc /sys /var/run /var/lock (so various utils will work)
#
/etc/rcS.d/S02mountkernfs.sh start
#
# mount udev (necessary so that tssdcarda device will appear)
#
/etc/rcS.d/S03udev start
#
# load tssdcard.ko
#
TSSDCARD="/lib/modules/`uname -r`/tssdcard.ko"
if [ ! -f "$TSSDCARD" ] ; then
fail "$TSSDCARD not found"
fi
insmod "$TSSDCARD"
#
# make sure device is there
#
# XXX screw it. these tests don't seem to work
#
#ls -l /dev/tssdcarda
echo 'sleeping a few seconds...'
sleep 5
#ls -l /dev/tssdcarda
#
#case "`ls -l /dev/tssdcarda`" in
# b*) ;;
# *) fail block device /dev/tssdcarda not found ;;
#esac
#
# look for the first linux partition on that device
#
device=`fdisk -l /dev/tssdcarda | awk '$NF ~ /Linux/ {print $1; exit}'`
echo found $device
#case "`ls -l $device`" in
# b*) ;;
# *) fail block device $device not found ;;
#esac
#
# fsck $device
#
fsck -a $device
case $? in
0) ;; #no errors
1) ;; #errors corrected
*) fail fsck errors on $device ;;
esac
#
# newroot
#
[ -d /sdroot ] || mkdir /sdroot
mount $device /sdroot
if [ ! -f /sdroot/sbin/init ] ; then
umount /sdroot
fail no /sbin/init on $device
fi
#
# chroot has to be in both places, because implementations of pivot_root
# differ in details - we don't know which one we're going to get
#
if [ ! -f /usr/sbin/chroot ] ; then
fail no /usr/sbin/chroot
fi
if [ ! -f /sdroot/usr/sbin/chroot ] ; then
fail no /sdroot/usr/sbin/chroot
fi
#
# move mounted devices
#
for dir in /proc /sys /var/run /var/lock /proc/bus/usb
/dev/.static/dev /dev /lib/init/rw ; do
[ -d /sdroot$dir ] || mkdir -p /sdroot$dir
mount --move $dir /sdroot$dir
done
#
# now move the root
#
cd /sdroot
[ -d oldroot ] || mkdir oldroot
pivot_root . oldroot
case $? in
0) ;;
*) fail pivot_root reported status $?;;
esac
exec chroot . /sbin/init
fail chroot failed status $?
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|