Skip to contentSkip to conversation

Fixes for read-only-rootfs

PATCH In review Paul Eggleton 2 participants 7 messages Apr 10, 2013 – Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

cover Fixes for read-only-rootfs

There were a number of things breaking read-only-rootfs support; this patchset fixes the most serious issues.

The following changes since commit f9d88a559dd2479893d7570676d42955ee3b8845:

tinylogin: Fix mix of tabs and spaces for SRC_URI indentation (2013-04-10 13:15:14 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib paule/read-only-rootfs-fixes
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/read-only-rootfs-fixes

Paul Eggleton (4):
rpm-postinsts: don't create broken postinst script
rpm-postinsts: avoid errors during boot with read-only-rootfs enabled
initscripts: fix read-only-rootfs-hook.sh to avoid using unionfs
initscripts: fix read-only-rootfs-hook.sh to start earlier

 .../initscripts-1.0/read-only-rootfs-hook.sh           |   16 +++++-----------
 meta/recipes-core/initscripts/initscripts_1.0.bb       |    2 +-
 meta/recipes-devtools/rpm/rpm-postinsts.bb             |   12 ++++++------
 3 files changed, 12 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/4 rpm-postinsts: don't create broken postinst script

Not only was the variable reference in this line broken, but it wasn't going to work anyway - we install the script directly into /etc/rcS.d and not into /etc/init.d, so the code in update-rc.d.bbclass couldn't find anything there. This resulted in a postinstall script for rpm-postinsts being created in /etc/rpm-postinsts which can't work when the root filesystem is read-only. To simplify things just remove the use of update-rc.d.bbclass since we don't really need the added complexity here.

Fixes [YOCTO #4222].

---
 meta/recipes-devtools/rpm/rpm-postinsts.bb |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
meta/recipes-devtools/rpm/rpm-postinsts.bb +1 -4
index 27ef2aa..0a62da0 100644
@@ -5,15 +5,12 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/LGPL-2.1;md5=1
 
 RDEPENDS_${PN} = "base-files"
 
-inherit update-rc.d allarch
+inherit allarch
 #
 # Allow distributions to alter when [postponed] package install scripts are run
 #
 POSTINSTALL_INITPOSITION ?= "98"
 
-INITSCRIPT_NAME = "run-postinsts"
-INITSCRIPT_PARAMS = "start ${{POSTINSTALL_INITPOSITION} S ."
-
 POSTLOG ?= "/var/log/postinstall.log"
 REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>>${POSTLOG} 2>&1', '', d)}"
 
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH 2/4 rpm-postinsts: avoid errors during boot with read-only-rootfs enabled

In reply to Paul Eggleton

* If /etc/rpm-postinsts doesn't exist, don't error
* If deleting the script errors, don't bother printing it (this will always happen if the root filesystem is read-only)

---
 meta/recipes-devtools/rpm/rpm-postinsts.bb |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/recipes-devtools/rpm/rpm-postinsts.bb +5 -2
index 0a62da0..fb05ad6 100644
@@ -32,7 +32,10 @@ do_install() {
 	i=\$i
 	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
 #!/bin/sh
-for i in \`ls /etc/rpm-postinsts/\`; do
+
+. /etc/default/rcS
+
+[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
 	i=/etc/rpm-postinsts/$i
 	echo "Running postinst $i..."
 	if [ -f $i ] && $i ${REDIRECT_CMD}; then
@@ -41,7 +44,7 @@ for i in \`ls /etc/rpm-postinsts/\`; do
 		echo "ERROR: postinst $i failed."
 	fi
 done
-rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
+rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
 EOF
 	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
 }
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 3/4 initscripts: fix read-only-rootfs-hook.sh to avoid using unionfs

In reply to Paul Eggleton

Unionfs isn't available everywhere, and we can get similar results (if not quite as neatly) by using bind mounts + tmpfs and copying the data over.

---
 .../initscripts-1.0/read-only-rootfs-hook.sh            |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +4 -11
index 3a295ee..4f3e0d9 100644
@@ -4,16 +4,9 @@
 
 [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
 
-# Make sure unionfs is in /proc/filesystems
-if ! grep -q unionfs /proc/filesystems; then
-    echo "ERROR: unionfs not supported by kernel!"
-    exit 1
+if [ "$1" = "start" ] ; then
+	mkdir -p /var/volatile/lib
+	cp -a /var/lib/* /var/volatile/lib
+	mount --bind /var/volatile/lib /var/lib
 fi
 
-mkdir -p /var/volatile/lib
-mount -t unionfs -o dirs=/var/volatile/lib:/var/lib=ro none /var/lib
-
-if [ $? != 0 ]; then
-    echo "ERROR: Union mount failed!"
-    exit 1
-fi
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 4/4 initscripts: fix read-only-rootfs-hook.sh to start earlier

In reply to Paul Eggleton

Mount /var/volatile ourselves so that we can set up the writable area first. This fixes the urandom service not starting properly when read-only-rootfs is enabled.

---
 .../initscripts/initscripts-1.0/read-only-rootfs-hook.sh             |    1 +
 meta/recipes-core/initscripts/initscripts_1.0.bb                     |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +1 -0
index 4f3e0d9..9cf0921 100644
@@ -5,6 +5,7 @@
 [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
 
 if [ "$1" = "start" ] ; then
+	grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile
 	mkdir -p /var/volatile/lib
 	cp -a /var/lib/* /var/volatile/lib
 	mount --bind /var/volatile/lib /var/lib
meta/recipes-core/initscripts/initscripts_1.0.bb +1 -1
index 649e182..531b2b6 100644
@@ -118,7 +118,7 @@ do_install () {
 	update-rc.d -r ${D} bootmisc.sh start 55 S .
 	update-rc.d -r ${D} sysfs.sh start 02 S .
 	update-rc.d -r ${D} populate-volatile.sh start 37 S .
-	update-rc.d -r ${D} read-only-rootfs-hook.sh start 41 S .
+	update-rc.d -r ${D} read-only-rootfs-hook.sh start 29 S .
 	update-rc.d -r ${D} devpts.sh start 38 S .
 	if [ "${TARGET_ARCH}" = "arm" ]; then
 	        update-rc.d -r ${D} alignment.sh start 06 S .
Signature · 1 line
1.7.10.4
#5 lore raw

Re: [PATCH 4/4] initscripts: fix read-only-rootfs-hook.sh to start earlier

Quoted 15 lines · On 10 April 2013 17:42:28 Paul Eggleton <[email protected]> wrote:

Mount /var/volatile ourselves so that we can set up the writable area first. This fixes the urandom service not starting properly when read-only-rootfs is enabled.

---
 .../initscripts/initscripts-1.0/read-only-rootfs-hook.sh             |    1 +
 meta/recipes-core/initscripts/initscripts_1.0.bb                     |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +0 -0
index 4f3e0d9..9cf0921 100644

meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh line 8

Quoted 4 lines
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +1 -0
@@ -5,6 +5,7 @@
 [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
 
 if [ "$1" = "start" ] ; then
+	grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile

Or just use mountpoint(1)?

Sent with AquaMail for Android
http://www.aqua-mail.com

#6 lore raw

Re: [PATCH 4/4] initscripts: fix read-only-rootfs-hook.sh to start earlier

Quoted 1 line · On Thursday 11 April 2013 08:29:49 Bernhard Reutner-Fischer wrote:

On 10 April 2013 17:42:28 Paul Eggleton <[email protected]>

Quoted 21 lines · wrote:
Quoted 21 lines

Mount /var/volatile ourselves so that we can set up the writable area first. This fixes the urandom service not starting properly when read-only-rootfs is enabled.

---

.../initscripts/initscripts-1.0/read-only-rootfs-hook.sh |
1 + meta/recipes-core/initscripts/initscripts_1.0.bb
| 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh index 4f3e0d9..9cf0921 100644
---
a/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
+++
b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh

(quoted diff) +0 -0
@@ -5,6 +5,7 @@
 
Quoted 7 lines

meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh line 8

Quoted 5 lines
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +1 -0
 [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
 
 if [ "$1" = "start" ] ; then
 
+	grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile

Or just use mountpoint(1)?

That would have been a better choice if I had known about it, yes. I'll send a patch to change it.

Thanks,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre