[package] extroot: block-mount block-extroot: Added ability to do a whole disk extroo...
authorDaniel Dickinson <crazycshore@gmail.com>
Sun, 13 Mar 2011 09:24:24 +0000 (09:24 +0000)
committerDaniel Dickinson <crazycshore@gmail.com>
Sun, 13 Mar 2011 09:24:24 +0000 (09:24 +0000)
SVN-Revision: 26109

package/block-extroot/files/50_determine_usb_root
package/block-extroot/files/55_determine_extroot_sysupgrade
package/block-extroot/files/60_pivot_usb_root
package/block-extroot/files/extmount.sh
package/block-mount/files/mount.sh

index e87855c2a7777a502007cbec8adbe88748cbba20..8c5841e32b08aa3839beb4359674374cf6e2f31e 100644 (file)
@@ -37,10 +37,17 @@ determine_external_root() {
                } 
                config_load fstab
                config_foreach config_mount_by_section mount 1
+               ER_OVERLAY_ROM="/no-extroot"
                
                [ "$rootfs_found" = "1" ] && grep -q ' /overlay ' /proc/mounts && { 
                        pi_extroot_mount_success=true
                        pi_mount_skip_next=false
+                       ER_OVERLAY_ROM="/overlay"
+               }
+               [ "$rootfs_found" = "1" ] && grep -q ' /rom ' /proc/mounts && { 
+                       pi_extroot_mount_success=true
+                       pi_mount_skip_next=false
+                       ER_OVERLAY_ROM="/rom"
                }
        }
        UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
index 5a6ad04f89986d82953b9b6184bb4d67ec34fcbc..d458b63bb1c3505991be2b0762c967be59011d8b 100644 (file)
@@ -13,7 +13,7 @@ check_set_md5sum() {
                er_extroot_md5sum="$(cat $er_md5sum_file)"
        fi
 
-       local er_overlay_file="/overlay/etc/extroot.md5sum"
+       local er_overlay_file="${ER_OVERLAY_ROM}/etc/extroot.md5sum"
 
        local er_extroot_overlay_md5sum
        if [ -f "$er_overlay_file" ]; then
@@ -24,8 +24,8 @@ check_set_md5sum() {
                cat $er_md5sum_file >$er_overlay_file
        elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
                pi_extroot_mount_success="false"
-               mkdir -p /tmp/overlay-disabled
-               mount --move /overlay /tmp/overlay-disabled
+               mkdir -p /tmp${ER_OVERLAY_ROM}-disabled
+               mount --move ${ER_OVERLAY_ROM} /tmp${ER_OVERLAY_ROM}-disabled
        fi
 }
 
index 1c9be97cae9b015740d1ec791fdd6fe15fdbe36a..b610a4ade15e896dab42841d826ad23d0aa81b33 100644 (file)
@@ -9,10 +9,17 @@
 external_root_pivot() {
        check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
                echo "switching to external rootfs"
-               if [ "$ER_IS_SQUASHFS" = "true" ]; then
-                       umount /tmp/overlay
+               if [ "$ER_OVERLAY_ROM" = "/overlay" ]; then
+                       if [ "$ER_IS_SQUASHFS" = "true" ]; then
+                               umount /tmp/overlay
+                       fi
+                       mount -o remount,ro / && fopivot /overlay /rom && pi_mount_skip_next=true
+               elif [ "$ER_OVERLAY_ROM" = "/rom" ]; then
+                       if [ "$ER_IS_SQUASHFS" = "true" ]; then
+                               umount /tmp/overlay
+                       fi
+                       mount -o remount,ro / && pivot_rom /rom /rom && pi_mount_skip_next=true
                fi
-               mount -o remount,ro / && fopivot /overlay /rom && pi_mount_skip_next=true
        }
 }
 
index 1d5ebf26fab74b294646fb69f6f93a779999d7f8..44d662e63affd1f5156108a770af43d0d1bffe43 100644 (file)
@@ -24,3 +24,13 @@ er_load_modules() {
        rm -rf /tmp/extroot_modules
 }
 
+pivot_rom() { # <new_root> <old_root>
+       mount -o move /proc $1/proc && \
+       pivot_root $1 $1$2 && {
+               mount -o move $2/dev /dev
+               mount -o move $2/tmp /tmp
+               mount -o move $2/sys /sys 2>&-
+               return 0
+       }
+}
+
index 3056c73aa94402edf6a8e657573a8a8ac1dc4a9a..d82a927835ef073ae9f85a1725f7b8f2b887556c 100644 (file)
@@ -41,10 +41,14 @@ config_mount_by_section() {
                                if [ "$find_rootfs" = "1" ]; then
                                    if [ "$is_rootfs" -eq 1 ]; then
                                        target=/overlay
+                                   elif [ "$target" = "/" ]; then
+                                       target=/rom
                                    fi
                                else
                                    if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
                                        target=/tmp/overlay-disabled
+                                   elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
+                                       target="/tmp/rom-disabled"
                                    fi
                                fi
                                
@@ -59,6 +63,9 @@ config_mount_by_section() {
                    [ "$target" = "/overlay" ] && {
                        rootfs_found=1
                    }
+                   [ "$target" = "/rom" ] && {
+                       rootfs_found=1
+                   }
                }
                return 0        
        }