From: "Yong, Jonathan" <jonathan.yong@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [RFC] Hybrid live image?
Date: Fri, 28 Apr 2017 10:09:42 +0800 [thread overview]
Message-ID: <5902A466.7020508@intel.com> (raw)
[-- 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
reply other threads:[~2017-04-28 2:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5902A466.7020508@intel.com \
--to=jonathan.yong@intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox