extmount.sh 1.1 KB

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