summaryrefslogtreecommitdiffstats
path: root/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh')
-rw-r--r--recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh47
1 files changed, 34 insertions, 13 deletions
diff --git a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
index ff6a774..be62db0 100644
--- a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
+++ b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh
@@ -18,6 +18,14 @@ ROOT_ROMOUNT="/media/rfs/ro"
18ROOT_RWMOUNT="/media/rfs/rw" 18ROOT_RWMOUNT="/media/rfs/rw"
19ROOT_RWRESET="no" 19ROOT_RWRESET="no"
20 20
21ROOT_ROFSTYPE=""
22ROOT_ROMOUNTOPTIONS="bind"
23ROOT_ROMOUNTOPTIONS_DEVICE="noatime,nodiratime"
24
25ROOT_RWFSTYPE=""
26ROOT_RWMOUNTOPTIONS="rw,noatime,mode=755 tmpfs"
27ROOT_RWMOUNTOPTIONS_DEVICE="rw,noatime,mode=755"
28
21early_setup() { 29early_setup() {
22 mkdir -p /proc 30 mkdir -p /proc
23 mkdir -p /sys 31 mkdir -p /sys
@@ -36,17 +44,23 @@ read_args() {
36 root=*) 44 root=*)
37 ROOT_RODEVICE=$optarg ;; 45 ROOT_RODEVICE=$optarg ;;
38 rootfstype=*) 46 rootfstype=*)
47 ROOT_ROFSTYPE="$optarg"
39 modprobe $optarg 2> /dev/null || \ 48 modprobe $optarg 2> /dev/null || \
40 log "Could not load $optarg module";; 49 log "Could not load $optarg module";;
41 rootinit=*) 50 rootinit=*)
42 ROOT_ROINIT=$optarg ;; 51 ROOT_ROINIT=$optarg ;;
52 rootoptions=*)
53 ROOT_ROMOUNTOPTIONS_DEVICE="$optarg" ;;
43 rootrw=*) 54 rootrw=*)
44 ROOT_RWDEVICE=$optarg ;; 55 ROOT_RWDEVICE=$optarg ;;
45 rootrwfstype=*) 56 rootrwfstype=*)
57 ROOT_RWFSTYPE="$optarg"
46 modprobe $optarg 2> /dev/null || \ 58 modprobe $optarg 2> /dev/null || \
47 log "Could not load $optarg module";; 59 log "Could not load $optarg module";;
48 rootrwreset=*) 60 rootrwreset=*)
49 ROOT_RWRESET=$optarg ;; 61 ROOT_RWRESET=$optarg ;;
62 rootrwoptions=*)
63 ROOT_RWMOUNTOPTIONS_DEVICE="$optarg" ;;
50 init=*) 64 init=*)
51 INIT=$optarg ;; 65 INIT=$optarg ;;
52 esac 66 esac
@@ -75,19 +89,22 @@ mount_and_boot() {
75 # Build mount options for read only root file system. 89 # Build mount options for read only root file system.
76 # If no read-only device was specified via kernel command line, use 90 # If no read-only device was specified via kernel command line, use
77 # current root file system via bind mount. 91 # current root file system via bind mount.
78 ROOT_ROMOUNTOPTIONS_BIND="-o bind /" 92 ROOT_ROMOUNTPARAMS_BIND="-o ${ROOT_ROMOUNTOPTIONS} /"
79 if [ -z "${ROOT_RODEVICE}" ]; then 93 if [ -n "${ROOT_RODEVICE}" ]; then
80 ROOT_ROMOUNTOPTIONS="${ROOT_ROMOUNTOPTIONS_BIND}" 94 ROOT_ROMOUNTPARAMS="-o ${ROOT_ROMOUNTOPTIONS_DEVICE} $ROOT_RODEVICE"
95 if [ -n "${ROOT_ROFSTYPE}" ]; then
96 ROOT_ROMOUNTPARAMS="-t $ROOT_ROFSTYPE $ROOT_ROMOUNTPARAMS"
97 fi
81 else 98 else
82 ROOT_ROMOUNTOPTIONS="-o noatime,nodiratime $ROOT_RODEVICE" 99 ROOT_ROMOUNTPARAMS="$ROOT_ROMOUNTPARAMS_BIND"
83 fi 100 fi
84 101
85 # Mount root file system to new mount-point, if unsuccessful, try bind 102 # Mount root file system to new mount-point, if unsuccessful, try bind
86 # mounting current root file system. 103 # mounting current root file system.
87 if ! $MOUNT $ROOT_ROMOUNTOPTIONS "$ROOT_ROMOUNT" 2>/dev/null && \ 104 if ! $MOUNT $ROOT_ROMOUNTPARAMS "$ROOT_ROMOUNT" 2>/dev/null && \
88 [ "x$ROOT_ROMOUNTOPTIONS_BIND" == "x$ROOT_ROMOUNTOPTIONS" ] || \ 105 [ "x$ROOT_ROMOUNTPARAMS_BIND" == "x$ROOT_ROMOUNTPARAMS" ] || \
89 log "Could not mount $ROOT_RODEVICE, bind mounting..." && \ 106 log "Could not mount $ROOT_RODEVICE, bind mounting..." && \
90 ! $MOUNT $ROOT_ROMOUNTOPTIONS_BIND "$ROOT_ROMOUNT"; then 107 ! $MOUNT $ROOT_ROMOUNTPARAMS_BIND "$ROOT_ROMOUNT"; then
91 fatal "Could not mount read-only rootfs" 108 fatal "Could not mount read-only rootfs"
92 fi 109 fi
93 110
@@ -104,16 +121,20 @@ mount_and_boot() {
104 fi 121 fi
105 122
106 # Build mount options for read write root file system. 123 # Build mount options for read write root file system.
107 # If no read-write device was specified via kernel command line, use 124 # If a read-write device was specified via kernel command line, use
108 # tmpfs. 125 # it, otherwise default to tmpfs.
109 if [ -z "${ROOT_RWDEVICE}" ]; then 126 if [ -n "${ROOT_RWDEVICE}" ]; then
110 ROOT_RWMOUNTOPTIONS="-t tmpfs -o rw,noatime,mode=755 tmpfs" 127
128 ROOT_RWMOUNTPARAMS="-o $ROOT_RWMOUNTOPTIONS_DEVICE $ROOT_RWDEVICE"
129 if [ -n "${ROOT_RWFSTYPE}" ]; then
130 ROOT_RWMOUNTPARAMS="-t $ROOT_RWFSTYPE $ROOT_RWMOUNTPARAMS"
131 fi
111 else 132 else
112 ROOT_RWMOUNTOPTIONS="-o rw,noatime,mode=755 $ROOT_RWDEVICE" 133 ROOT_RWMOUNTPARAMS="-t tmpfs -o $ROOT_RWMOUNTOPTIONS"
113 fi 134 fi
114 135
115 # Mount read-write file system into initram root file system 136 # Mount read-write file system into initram root file system
116 if ! $MOUNT $ROOT_RWMOUNTOPTIONS $ROOT_RWMOUNT ; then 137 if ! $MOUNT $ROOT_RWMOUNTPARAMS $ROOT_RWMOUNT ; then
117 fatal "Could not mount read-write rootfs" 138 fatal "Could not mount read-write rootfs"
118 fi 139 fi
119 140