On Fri, 2008-07-11 at 16:01 -0400, Stefan Monnier wrote: > > Would you care to post your /sbin/mount_root here? > > I did a few weeks ago. > http://article.gmane.org/gmane.comp.embedded.openwrt.devel/1599
Here's an alternate implementation as per our discussion. In this case, do the USB (or IDE) root mount *after* the jffs. Seems work a treat here. Of course, after reflashing my router, before I can use the below to mount a USB storage device I have to: ipkg update ipkg install kmod-usb-core kmod-usb2 kmod-scsi-core kmod-usb-storage kmod-fs-ext3 to get the needed modules onto the jffs (as opposed to building them into the /rom). Thots (from anyone, not just Stefan -- my goal is to get this merged into the trunk after any discussion)? b. Index: package/base-files/files/sbin/mount_root =================================================================== --- package/base-files/files/sbin/mount_root (revision 11527) +++ package/base-files/files/sbin/mount_root (working copy) @@ -2,6 +2,62 @@ # Copyright (C) 2006 OpenWrt.org . /etc/functions.sh +### Try to mount some drive. #################### +mount_drive () { + local rootdev="$1" + + for m in jbd ext3; do + insmod "$m" + done + + # this may need to be higher if your disk is slow to initialize + n=10 + basesysdev=${rootdev%[0-9]} + sysdev=/sys/block/${basesysdev##/dev/} + while [ $n -gt 0 -a ! -e "$sysdev/dev" ]; do + echo "waiting for root device to be available...$n" >&2 + let n=n-1 + sleep 1 + done + + # loop either timed out, or found the device + if [ -e "$sysdev/dev" ]; then + # if it found the device, create the nodes for it + find $sysdev/ -name dev | while read file; do + dev=${file%/dev} + dev=${dev##*/} + # but only if it doesn't exist already + if [ ! -b /dev/$dev ]; then + echo "creating device node /dev/$dev" >&2 + IFS=: read major minor < $file + mknod /dev/$dev b $major $minor + fi + done + + mount "$rootdev" /mnt && [ -x /mnt/sbin/init ] && { + mkdir /mnt/oldroot + pivot /mnt /oldroot + exit + } + fi +} + +mount_ide () { + for m in ide-core aec62xx ide-generic ide-disk; do + insmod "$m" + done + mount_drive "/dev/hde1" + return 0 +} + +mount_usb () { + for m in usbcore ohci-hcd ehci-hcd scsi_mod sd_mod usb-storage; do + insmod "$m" + done + mount_drive "/dev/sda1" + return 0 +} + jffs2_ready () { mtdpart="$(find_mtd_part rootfs_data)" magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"') @@ -15,9 +71,21 @@ echo "switching to jffs2" mount "$(find_mtd_part rootfs_data)" /jffs -t jffs2 && \ fopivot /jffs /rom + if [ "$1" != "nousb" -a "$2" != "nousb" ]; then + mount_usb + fi + if [ "$1" != "noide" -a "$2" != "noide" ]; then + mount_ide + fi } || { echo "jffs2 not ready yet; using ramdisk" ramoverlay + if [ "$1" != "nousb" -a "$2" != "nousb" ]; then + mount_usb + fi + if [ "$1" != "noide" -a "$2" != "noide" ]; then + mount_ide + fi } } || { mtd unlock rootfs
signature.asc
Description: This is a digitally signed message part
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel