diff options
-rw-r--r-- | recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh | 18 |
1 files changed, 11 insertions, 7 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 b1e028f..9b53e40 100644 --- a/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh +++ b/recipes-core/initrdscripts/files/init-readonly-rootfs-overlay-boot.sh | |||
@@ -29,18 +29,19 @@ early_setup() { | |||
29 | read_args() { | 29 | read_args() { |
30 | [ -z "${CMDLINE+x}" ] && CMDLINE=`cat /proc/cmdline` | 30 | [ -z "${CMDLINE+x}" ] && CMDLINE=`cat /proc/cmdline` |
31 | for arg in $CMDLINE; do | 31 | for arg in $CMDLINE; do |
32 | optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` | 32 | # Set optarg to option parameter, and '' if no parameter was given |
33 | optarg=`expr "x$arg" : 'x[^=]*=\(.*\)' || echo ''` | ||
33 | case $arg in | 34 | case $arg in |
34 | root=*) | 35 | root=*) |
35 | ROOT_RODEVICE=$optarg ;; | 36 | ROOT_RODEVICE=$optarg ;; |
36 | rootfstype=*) | 37 | rootfstype=*) |
37 | modprobe $optarg 2> /dev/null ;; | 38 | modprobe $optarg 2> /dev/null || true;; |
38 | rootinit=*) | 39 | rootinit=*) |
39 | ROOT_ROINIT=$optarg ;; | 40 | ROOT_ROINIT=$optarg ;; |
40 | rootrw=*) | 41 | rootrw=*) |
41 | ROOT_RWDEVICE=$optarg ;; | 42 | ROOT_RWDEVICE=$optarg ;; |
42 | rootrwfstype=*) | 43 | rootrwfstype=*) |
43 | modprobe $optarg 2> /dev/null ;; | 44 | modprobe $optarg 2> /dev/null || true;; |
44 | rootrwreset=*) | 45 | rootrwreset=*) |
45 | ROOT_RWRESET=$optarg ;; | 46 | ROOT_RWRESET=$optarg ;; |
46 | init=*) | 47 | init=*) |
@@ -66,15 +67,18 @@ mount_and_boot() { | |||
66 | 67 | ||
67 | # Build mount options for read only root filesystem. | 68 | # Build mount options for read only root filesystem. |
68 | # If no read-only device was specified via kernel commandline, use current | 69 | # If no read-only device was specified via kernel commandline, use current |
69 | # rootfs. | 70 | # rootfs via bind mount. |
71 | ROOT_ROMOUNTOPTIONS_BIND="-o bind,ro /" | ||
70 | if [ -z "${ROOT_RODEVICE}" ]; then | 72 | if [ -z "${ROOT_RODEVICE}" ]; then |
71 | ROOT_ROMOUNTOPTIONS="--bind,ro /" | 73 | ROOT_ROMOUNTOPTIONS="${ROOT_ROMOUNTOPTIONS_BIND}" |
72 | else | 74 | else |
73 | ROOT_ROMOUNTOPTIONS="-o ro,noatime,nodiratime $ROOT_RODEVICE" | 75 | ROOT_ROMOUNTOPTIONS="-o ro,noatime,nodiratime $ROOT_RODEVICE" |
74 | fi | 76 | fi |
75 | 77 | ||
76 | # Mount rootfs as read-only to mount-point | 78 | # Mount rootfs as read-only to mount-point, if unsuccessful, |
77 | if ! $MOUNT $ROOT_ROMOUNTOPTIONS $ROOT_ROMOUNT ; then | 79 | # try bind mount current rootfs |
80 | if ! $MOUNT $ROOT_ROMOUNTOPTIONS $ROOT_ROMOUNT && \ | ||
81 | ! $MOUNT $ROOT_ROMOUNTOPTIONS_BIND $ROOT_ROMOUNT; then | ||
78 | fatal "Could not mount read-only rootfs" | 82 | fatal "Could not mount read-only rootfs" |
79 | fi | 83 | fi |
80 | 84 | ||