add block-extroot, a package for using an external filesystem as rootfs (patch by...
[openwrt.git] / package / block-extroot / files / 50_determine_usb_root
1 #!/bin/sh
2 # Copyright (C) 2010 Vertical Communications
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
5
6
7 . /etc/functions.sh
8 . /lib/functions/extmount.sh
9 . /lib/functions/mount.sh
10
11 determine_external_root() {
12 local OLD_UCI_CONFIG_DIR="$UCI_CONFIG_DIR"
13 set_jffs_mp
14 determine_root_device
15
16 # extroot requires extroot and fstab config files, therefore
17 # we assume configuration is incomplete and not to be used if either of them
18 # is missing (for jffs versions of these files on squashfs image)
19 if [ "$jffs" = "/jffs" ] && [ -r "/jffs/etc/config/fstab" ]; then
20 UCI_CONFIG_DIR="/jffs/etc/config"
21 ER_IS_SQUASHFS=true
22 fi
23
24 # For squashfs on firstboot root_device will be tmpfs for the ramoverlay,
25 # unless there is a saved config, in which case it will be /dev/root,
26 # however in the case of a saved config, it won't be restored until after
27 # this script, so there won't be a config on the first boot after
28 # flashing a squashfs-based filesystem
29 # For ext2, ramdisk, or jffs2 root filesystems root_device is /dev/root
30 # For squashfs after firstboot, root filesystem is /dev/root
31 # We only use the config from the root or jffs if the root_device is
32 # /dev/root
33 [ "$root_device" = "/dev/root" ] && {
34 er_load_modules
35 [ -n "$extroot_settle_time" ] && [ "$extroot_settle_time" -gt 0 ] && {
36 sleep $extroot_settle_time
37 }
38 config_load fstab
39 config_foreach config_mount_by_section mount 1
40
41 [ "$rootfs_found" = "1" ] && grep -q /overlay /proc/mounts && {
42 pi_extroot_mount_success=true
43 pi_mount_skip_next=false
44 }
45 }
46 UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
47 }
48
49 boot_hook_add preinit_mount_root determine_external_root
50
This page took 0.089751 seconds and 5 git commands to generate.