diff options
| -rw-r--r-- | meta/recipes-core/initrdscripts/files/init-live.sh | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh index 861d874657..df0076dd84 100644 --- a/meta/recipes-core/initrdscripts/files/init-live.sh +++ b/meta/recipes-core/initrdscripts/files/init-live.sh | |||
| @@ -137,12 +137,23 @@ do | |||
| 137 | sleep 1 | 137 | sleep 1 |
| 138 | done | 138 | done |
| 139 | 139 | ||
| 140 | # Try to make a union mount of the root image. | 140 | # Try to mount the root image read-write and then boot it up. |
| 141 | # If no unification filesystem is available, mount the image read-only. | 141 | # This function distinguishes between a read-only image and a read-write image. |
| 142 | # In the former case (typically an iso), it tries to make a union mount if possible. | ||
| 143 | # In the latter case, the root image could be mounted and then directly booted up. | ||
| 142 | mount_and_boot() { | 144 | mount_and_boot() { |
| 143 | mkdir $ROOT_MOUNT | 145 | mkdir $ROOT_MOUNT |
| 144 | mknod /dev/loop0 b 7 0 2>/dev/null | 146 | mknod /dev/loop0 b 7 0 2>/dev/null |
| 145 | 147 | ||
| 148 | if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then | ||
| 149 | fatal "Could not mount rootfs image" | ||
| 150 | fi | ||
| 151 | |||
| 152 | if touch $ROOT_MOUNT/bin 2>/dev/null; then | ||
| 153 | # The root image is read-write, directly boot it up. | ||
| 154 | boot_live_root | ||
| 155 | fi | ||
| 156 | |||
| 146 | # determine which unification filesystem to use | 157 | # determine which unification filesystem to use |
| 147 | union_fs_type="" | 158 | union_fs_type="" |
| 148 | if grep -q -w "overlayfs" /proc/filesystems; then | 159 | if grep -q -w "overlayfs" /proc/filesystems; then |
| @@ -157,9 +168,9 @@ mount_and_boot() { | |||
| 157 | case $union_fs_type in | 168 | case $union_fs_type in |
| 158 | "overlayfs") | 169 | "overlayfs") |
| 159 | mkdir -p /rootfs.ro /rootfs.rw | 170 | mkdir -p /rootfs.ro /rootfs.rw |
| 160 | if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs.ro; then | 171 | if ! mount -n --move $ROOT_MOUNT /rootfs.ro; then |
| 161 | rm -rf /rootfs.ro /rootfs.rw | 172 | rm -rf /rootfs.ro /rootfs.rw |
| 162 | fatal "Could not mount rootfs image" | 173 | fatal "Could not move rootfs mount point" |
| 163 | else | 174 | else |
| 164 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw | 175 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw |
| 165 | mount -t overlayfs -o "lowerdir=/rootfs.ro,upperdir=/rootfs.rw" overlayfs $ROOT_MOUNT | 176 | mount -t overlayfs -o "lowerdir=/rootfs.ro,upperdir=/rootfs.rw" overlayfs $ROOT_MOUNT |
| @@ -170,9 +181,9 @@ mount_and_boot() { | |||
| 170 | ;; | 181 | ;; |
| 171 | "aufs") | 182 | "aufs") |
| 172 | mkdir -p /rootfs.ro /rootfs.rw | 183 | mkdir -p /rootfs.ro /rootfs.rw |
| 173 | if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs.ro; then | 184 | if ! mount -n --move $ROOT_MOUNT /rootfs.ro; then |
| 174 | rm -rf /rootfs.ro /rootfs.rw | 185 | rm -rf /rootfs.ro /rootfs.rw |
| 175 | fatal "Could not mount rootfs image" | 186 | fatal "Could not move rootfs mount point" |
| 176 | else | 187 | else |
| 177 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw | 188 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw |
| 178 | mount -t aufs -o "dirs=/rootfs.rw=rw:/rootfs.ro=ro" aufs $ROOT_MOUNT | 189 | mount -t aufs -o "dirs=/rootfs.rw=rw:/rootfs.ro=ro" aufs $ROOT_MOUNT |
| @@ -182,11 +193,7 @@ mount_and_boot() { | |||
| 182 | fi | 193 | fi |
| 183 | ;; | 194 | ;; |
| 184 | "") | 195 | "") |
| 185 | if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then | 196 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs $ROOT_MOUNT/media |
| 186 | fatal "Could not mount rootfs image" | ||
| 187 | else | ||
| 188 | mount -t tmpfs -o rw,noatime,mode=755 tmpfs $ROOT_MOUNT/media | ||
| 189 | fi | ||
| 190 | ;; | 197 | ;; |
| 191 | esac | 198 | esac |
| 192 | 199 | ||
