Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/1] init-live.sh: distinguish between a read-only image and a read-write one
@ 2013-09-11  5:01 Qi.Chen
  2013-09-11  5:01 ` [PATCH 1/1] init-live.sh: distinguish between a read-only image and a read-write image Qi.Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Qi.Chen @ 2013-09-11  5:01 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

The following changes since commit e15dc0911656d4fe44025e71ed3b6763841b05db:

  mount.sh: automount cdrom device even if no ID_FS_TYPE available (2013-09-10 21:19:17 +0800)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib ChenQi/init-live-iso-hddimg
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/init-live-iso-hddimg

Chen Qi (1):
  init-live.sh: distinguish between a read-only image and a read-write
    image

 meta/recipes-core/initrdscripts/files/init-live.sh |   29 ++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)

-- 
1.7.9.5



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] init-live.sh: distinguish between a read-only image and a read-write image
  2013-09-11  5:01 [PATCH 0/1] init-live.sh: distinguish between a read-only image and a read-write one Qi.Chen
@ 2013-09-11  5:01 ` Qi.Chen
  2013-09-11  9:15   ` Burton, Ross
  0 siblings, 1 reply; 3+ messages in thread
From: Qi.Chen @ 2013-09-11  5:01 UTC (permalink / raw)
  To: openembedded-core

From: Chen Qi <Qi.Chen@windriver.com>

The iso and hddimg share a common concept of 'live image', and they
use the same initramfs and thus the same init. However, that init
script in initramfs made a wrong assumption that the rootfs image
was read-only by itself. This is apparently not true for hddimg.

To make things work as expected, this init script should at least
distinguish between a read-only rootfs image and a read-write one.

This patch adds this ability to the init script. After this change,
the init script would be able to check whether the rootfs image is
read-only or not. If the rootfs image is read-write, the image will
be mounted and then booted directly. No union mounts will be attempted
in this case.

[YOCTO #5164]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/initrdscripts/files/init-live.sh |   29 ++++++++++++--------
 1 file 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 861d874..df0076d 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -137,12 +137,23 @@ do
   sleep 1
 done
 
-# Try to make a union mount of the root image.
-# If no unification filesystem is available, mount the image read-only.
+# 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.
+# In the latter case, the root image could be mounted and then directly booted up.
 mount_and_boot() {
     mkdir $ROOT_MOUNT
     mknod /dev/loop0 b 7 0 2>/dev/null
 
+    if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
+	fatal "Could not mount rootfs image"
+    fi
+
+    if touch $ROOT_MOUNT/bin 2>/dev/null; then
+	# The root image is read-write, directly boot it up.
+	boot_live_root
+    fi
+
     # determine which unification filesystem to use
     union_fs_type=""
     if grep -q -w "overlayfs" /proc/filesystems; then
@@ -157,9 +168,9 @@ mount_and_boot() {
     case $union_fs_type in
 	"overlayfs")
 	    mkdir -p /rootfs.ro /rootfs.rw
-	    if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs.ro; then
+	    if ! mount -n --move $ROOT_MOUNT /rootfs.ro; then
 		rm -rf /rootfs.ro /rootfs.rw
-		fatal "Could not mount rootfs image"
+		fatal "Could not move rootfs mount point"
 	    else
 		mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
 		mount -t overlayfs -o "lowerdir=/rootfs.ro,upperdir=/rootfs.rw" overlayfs $ROOT_MOUNT
@@ -170,9 +181,9 @@ mount_and_boot() {
 	    ;;
 	"aufs")
 	    mkdir -p /rootfs.ro /rootfs.rw
-	    if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs.ro; then
+	    if ! mount -n --move $ROOT_MOUNT /rootfs.ro; then
 		rm -rf /rootfs.ro /rootfs.rw
-		fatal "Could not mount rootfs image"
+		fatal "Could not move rootfs mount point"
 	    else
 		mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
 		mount -t aufs -o "dirs=/rootfs.rw=rw:/rootfs.ro=ro" aufs $ROOT_MOUNT
@@ -182,11 +193,7 @@ mount_and_boot() {
 	    fi
 	    ;;
 	"")
-	    if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
-		fatal "Could not mount rootfs image"
-	    else
-		mount -t tmpfs -o rw,noatime,mode=755 tmpfs $ROOT_MOUNT/media
-	    fi
+	    mount -t tmpfs -o rw,noatime,mode=755 tmpfs $ROOT_MOUNT/media
 	    ;;
     esac
 
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] init-live.sh: distinguish between a read-only image and a read-write image
  2013-09-11  5:01 ` [PATCH 1/1] init-live.sh: distinguish between a read-only image and a read-write image Qi.Chen
@ 2013-09-11  9:15   ` Burton, Ross
  0 siblings, 0 replies; 3+ messages in thread
From: Burton, Ross @ 2013-09-11  9:15 UTC (permalink / raw)
  To: ChenQi; +Cc: OE-core

On 11 September 2013 06:01,  <Qi.Chen@windriver.com> wrote:
> The iso and hddimg share a common concept of 'live image', and they
> use the same initramfs and thus the same init. However, that init
> script in initramfs made a wrong assumption that the rootfs image
> was read-only by itself. This is apparently not true for hddimg.

Works for me, thanks.

Acked-By: Ross Burton <ross.burton@intel.com>

Ross


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-11  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11  5:01 [PATCH 0/1] init-live.sh: distinguish between a read-only image and a read-write one Qi.Chen
2013-09-11  5:01 ` [PATCH 1/1] init-live.sh: distinguish between a read-only image and a read-write image Qi.Chen
2013-09-11  9:15   ` Burton, Ross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox