extmount.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. # Copyright 2010 Vertical Communications
  3. # This is free software, licensed under the GNU General Public License v2.
  4. # See /LICENSE for more information.
  5. determine_root_device() {
  6. root_device="$(mount | grep ' / ' | cut -f1 -d\ | grep -v rootfs )"
  7. }
  8. set_jffs_mp() {
  9. jffs="$(awk '/jffs2/ {print $2}' /proc/mounts)"
  10. }
  11. er_load_modules() {
  12. mkdir -p /tmp/extroot_modules/modules.d
  13. mkdir -p /tmp/extroot_modules/modules
  14. ln -sf /etc/modules.d/* /tmp/overlay/etc/modules.d/* /tmp/extroot_modules/modules.d
  15. ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules
  16. local modules="$(grep -l '# May be required for rootfs' /tmp/extroot_modules/modules.d/* 2>/dev/null)"
  17. cd /tmp/extroot_modules/modules && [ -n "$modules" ] && {
  18. cat $modules | sed -e 's/^\([^#].*\)/insmod \.\/\1.ko/'| sh 2>&- || :
  19. }
  20. rm -rf /tmp/extroot_modules
  21. }
  22. pivot_rom() { # <new_root> <old_root>
  23. mount -o move /proc $1/proc && \
  24. pivot_root $1 $1$2 && {
  25. mount -o move $2/dev /dev
  26. mount -o move $2/tmp /tmp
  27. mount -o move $2/sys /sys 2>&-
  28. return 0
  29. }
  30. }