> I am having a hard time to find the place where mounting root "/" really
> happens ..
It's in /sbin/mount_root. And yes, it is not exactly trivial to find
(although in retrospect I had to admit that the name should have made it
pretty obvious).
See below the patch I use on my WL-700gE to mount the IDE drive's partition.
Stefan
Index: mount_root
===================================================================
--- mount_root (révision 14605)
+++ mount_root (copie de travail)
@@ -2,15 +2,75 @@
# Copyright (C) 2006 OpenWrt.org
. /etc/functions.sh
+echo mount_root >>/tmp/stef
+
jffs2_ready () {
mtdpart="$(find_mtd_part rootfs_data)"
magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
[ "$magic" != "deadc0de" ]
}
+### Try to mount some drive. ####################
+mount_drive () {
+ # for m in jbd ext3; do
+ # echo "mount_drive $m" >>/tmp/stef
+ # insmod "$m" >>/tmp/stef 2>&1
+ # done
+
+ rootdev="$1"
+
+ COUNTER=0
+ while [ ! -b "$rootdev" ] && [ $COUNTER -lt 10 ]; do
+ echo "mount sleep for $rootdev" >>/tmp/stef
+ sleep 1
+ let COUNTER=COUNTER+1
+ done
+
+ mount "$rootdev" /mnt && [ -x /mnt/sbin/init ] && {
+ echo "mounted $rootdev" >>/tmp/stef
+ . /bin/firstboot
+ pivot /mnt /rom
+ exit
+ }
+}
+
+# mount_ide () {
+# echo mount_ide >>/tmp/stef
+# for m in ide-core aec62xx ide-generic ide-disk; do
+# insmod "$m" >>/tmp/stef 2>&1
+# done
+# mount_drive "/dev/hde1"
+# }
+
+# mount_usb () {
+# echo mount_usb >>/tmp/stef
+# # ehci-hcd is for USB2, ohci-hcd and uhci-hcd are both for USB1 but only
+# # one of them works. For WRTSL54GS, it's ohci, for WL700gE it's uhci.
+# for m in usbcore ohci-hcd uhci-hcd ehci-hcd scsi_mod sd_mod usb-storage;
do
+# echo "mount_usb $m" >>/tmp/stef
+# insmod "$m" >>/tmp/stef 2>&1
+# done
+# mount_drive "/dev/sda1"
+# }
+
+#mount_usb
+#mount_ide
+(cd /etc/modules.d && load_modules *)
+# GPIO 6 on WL-700gE is the `copy' button; if the button is released,
+# gpioctl returns 0, and it return 64 if it is pressed.
+# GPIO 4 on WL-700gE is the `ezsetup' button; if the button is released,
+# gpioctl returns 0, and it return 16 if it is pressed.
+if gpioctl get 6 >/dev/null && gpioctl get 4 >/dev/null; then
+ # FIXME: This device name should come from a CONFIG_setting.
+ mount_drive /dev/hde1
+fi
+
+### If no drive, mount the JFFS2 partition or a ramdisk. ####################
grep rootfs_data /proc/mtd >/dev/null 2>/dev/null && {
+ echo mount_root-11 >>/tmp/stef
. /bin/firstboot
mtd unlock rootfs_data
+ echo mount_root-12 >>/tmp/stef
jffs2_ready && {
echo "switching to jffs2"
mount "$(find_mtd_part rootfs_data)" /jffs -t jffs2 && \
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel