All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Hybrid live image?
@ 2017-04-28  2:09 Yong, Jonathan
  0 siblings, 0 replies; only message in thread
From: Yong, Jonathan @ 2017-04-28  2:09 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

Hi,

Attached patch makes the init script attempt to find an writable image
to use with Overlay/AUFS, and probably does so poorly.

The idea is to eventually allow users to do a "RESET" option in case
they mess up the system. The underlying image can be something read-only
like cramfs or squashfs.

Any comments or suggestions?

[-- Attachment #2: init-live.txt --]
[-- Type: text/plain, Size: 2229 bytes --]

diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index 441b41c..35047c8 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -152,6 +152,25 @@ do
   sleep 1
 done
 
+try_rw_image() {
+    for i in /run/media/$ROOT_DISK/$ISOLINUX/${ROOT_IMAGE}.rw; do
+        if [ -w $i ]; then
+            mount -o rw,loop,noatime,sync $i /rootfs.rw
+            if [ "$?" -ne 0 ]; then
+                break
+            fi
+            touch /rootfs.rw/.rwtest 2>/dev/null
+            if [ "$?" -ne 0 ]; then
+                break
+            fi
+            rm /rootfs.rw/.rwtest
+            return
+        fi
+     done
+     umount /rootfs.rw
+     mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
+}
+
 # Try to mount the root image read-write and then boot it up.
 # This function distinguishes between a read-only image and a read-write image.
 # In the former case (typically an iso), it tries to make a union mount if possible.
@@ -159,6 +178,7 @@ done
 mount_and_boot() {
     mkdir $ROOT_MOUNT
     mknod /dev/loop0 b 7 0 2>/dev/null
+    mknod /dev/loop1 b 7 1 2>/dev/null
 
     if ! mount -o rw,loop,noatime,nodiratime /run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
 	fatal "Could not mount rootfs image"
@@ -187,7 +207,7 @@ mount_and_boot() {
 		rm -rf /rootfs.ro /rootfs.rw
 		fatal "Could not move rootfs mount point"
 	    else
-		mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
+		try_rw_image
 		mkdir -p /rootfs.rw/upperdir /rootfs.rw/work
 		mount -t overlay overlay -o "lowerdir=/rootfs.ro,upperdir=/rootfs.rw/upperdir,workdir=/rootfs.rw/work" $ROOT_MOUNT
 		mkdir -p $ROOT_MOUNT/rootfs.ro $ROOT_MOUNT/rootfs.rw
@@ -201,7 +221,7 @@ mount_and_boot() {
 		rm -rf /rootfs.ro /rootfs.rw
 		fatal "Could not move rootfs mount point"
 	    else
-		mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
+		try_rw_image
 		mount -t aufs -o "dirs=/rootfs.rw=rw:/rootfs.ro=ro" aufs $ROOT_MOUNT
 		mkdir -p $ROOT_MOUNT/rootfs.ro $ROOT_MOUNT/rootfs.rw
 		mount --move /rootfs.ro $ROOT_MOUNT/rootfs.ro

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-28  2:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-28  2:09 [RFC] Hybrid live image? Yong, Jonathan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.