Make read-only rootfs work with live images
v2 cover Make read-only rootfs work with live images
From: Chen Qi <[email protected]>
Change from V1:
1. Disable the generating of ssh keys at rootfs time
2. Add a mechanism to read-only-rootfs-hook.sh to check whether a directory is on a read-only partition.
3. Fix a new bug#4937 (https://bugzilla.yoctoproject.org/show_bug.cgi?id=4937)
The following changes since commit 7d8eda082e5bf8f2af30c6c7b6a8d4083055bd8c:
Revert "initrdscripts: mount / as read-only when live-booting" (2013-07-29 10:03:41 +0800)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib ChenQi/read-only-rootfs-in-live-images
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/read-only-rootfs-in-live-images
Chen Qi (10):
init-live.sh: make $ROOT_MOUNT/media writable when necessary use a uniform way to determine whether rootfs is read-only
udev: remove implicit dependency on initscripts populate-volatile.sh: use $ROOT_DIR/var/volatile/tmp as TMPDIR populate-volatile.sh: don't spawn background process at rootfs time
runqemu-internal: fix to start X correctly in live images
initscripts: use a uniform way to handle directories in read-only
rootfs
irda-utils: make /etc/sysconfig writable in read-only rootfs
lighttpd: make /www diretory writable in read-only rootfs
openssh: make /etc/ssh directory writable in read-only rootfs
meta/classes/image.bbclass | 4 -- .../irda-utils/irda-utils_0.9.18.bb | 4 ++ meta/recipes-connectivity/openssh/openssh_6.2p2.bb | 3 ++ meta/recipes-core/initrdscripts/files/init-live.sh | 2 + .../initscripts/initscripts-1.0/functions | 14 ++++++ .../initscripts-1.0/populate-volatile.sh | 12 +++-- .../initscripts-1.0/read-only-rootfs-hook.sh | 47 +++++++++++++++++--- meta/recipes-core/initscripts/initscripts_1.0.bb | 5 +++ meta/recipes-core/sysvinit/sysvinit/rcS-default | 4 -- meta/recipes-core/udev/udev/init | 21 +++++++-- meta/recipes-core/udev/udev/udev-cache | 5 +++ meta/recipes-extended/lighttpd/lighttpd_1.4.32.bb | 3 ++ .../0001-add-is_rootfs_readonly-to-functions.patch | 37 +++++++++++++++ meta/recipes-extended/lsb/lsbinitscripts_9.48.bb | 1 + scripts/runqemu-internal | 2 +- 15 files changed, 142 insertions(+), 22 deletions(-) create mode 100644 meta/recipes-extended/lsb/lsbinitscripts/0001-add-is_rootfs_readonly-to-functions.patch
Signature · 1 line
1.7.9.5
PATCH v2 1/10 init-live.sh: make $ROOT_MOUNT/media writable when necessary
From: Chen Qi <[email protected]>
If the live image is mounted as read-only, we cannot make necessary directories under $ROOT_MOUNT/media, so trying to move the mount points lead to errors.
So in case that no unification filesystem mechanism is available in kernel and the rootfs is mounted as read-only, we mount tmpfs on $ROOT_MOUNT/media so that it's possible to make necessary directories under it.
[YOCTO #4881]
[YOCTO #4103]
--- meta/recipes-core/initrdscripts/files/init-live.sh | 2 ++ 1 file changed, 2 insertions(+)
meta/recipes-core/initrdscripts/files/init-live.sh +2 -0
@@ -200,6 +200,8 @@ mount_and_boot() { "") 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 ;; esac
Signature · 1 line
1.7.9.5
PATCH v2 2/10 use a uniform way to determine whether rootfs is read-only
In reply to [email protected]From: Chen Qi <[email protected]>
Previously, we had two ways to check whether the rootfs was read-only. In some part of the system, we determined whether the rootfs is read-only by checking the fstab or /proc/mounts; in other part of the system, we used the value of ROOTFS_READ_ONLY in /etc/default/rcS as a criteria.
Having two ways to check the rootfs is confusing and makes systems inconsistent.
We should drop the use of ROOTFS_READ_ONLY and figure out a uniform and consistent way to determine whether rootfs is read-only.
This patch fixes this problem by using the following strategy.
On target, we use /proc/mounts to check whether / is read-only; on host, we use $ROOT_DIR/etc/fstab to check whether the rootfs is going to be mounted as read-only or not.
[YOCTO #4880]
[YOCTO #4103]
--- meta/classes/image.bbclass | 4 --- .../initscripts/initscripts-1.0/functions | 14 ++++++++ .../initscripts-1.0/populate-volatile.sh | 4 +++ .../initscripts-1.0/read-only-rootfs-hook.sh | 4 ++- meta/recipes-core/sysvinit/sysvinit/rcS-default | 4 --- meta/recipes-core/udev/udev/init | 5 +++ meta/recipes-core/udev/udev/udev-cache | 5 +++ .../0001-add-is_rootfs_readonly-to-functions.patch | 37 ++++++++++++++++++++ meta/recipes-extended/lsb/lsbinitscripts_9.48.bb | 1 + 9 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 meta/recipes-extended/lsb/lsbinitscripts/0001-add-is_rootfs_readonly-to-functions.patch
meta/classes/image.bbclass +0 -4
@@ -258,10 +258,6 @@ read_only_rootfs_hook () { if ${@base_contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then # Tweak the mount option and fs_passno for rootfs in fstab sed -i -e '/^[#[:space:]]*rootfs/{s/defaults/ro/;s/\([[:space:]]*[[:digit:]]\)\([[:space:]]*\)[[:digit:]]$/\1\20/}' ${IMAGE_ROOTFS}/etc/fstab - # Change the value of ROOTFS_READ_ONLY in /etc/default/rcS to yes - if [ -e ${IMAGE_ROOTFS}/etc/default/rcS ]; then - sed -i 's/ROOTFS_READ_ONLY=no/ROOTFS_READ_ONLY=yes/' ${IMAGE_ROOTFS}/etc/default/rcS - fi # Run populate-volatile.sh at rootfs time to set up basic files # and directories to support read-only rootfs. if [ -x ${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh ]; then
meta/recipes-core/initscripts/initscripts-1.0/functions +14 -0
@@ -58,3 +58,17 @@ status() { fi return 3 } + +# Determine whether rootfs is read-only or not according to /proc/mounts or /etc/fstab. +is_rootfs_readonly () { + local DIRNAME=`dirname $0` + local ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'` + local criteria_file + [ -n "$ROOT_DIR" ] && criteria_file="$ROOT_DIR/etc/fstab" || criteria_file="/proc/mounts" + local flag + for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' < $criteria_file`; do + [ "$flag" = "ro" ] && { echo "yes"; return 0; } + done + echo "no" + return 0 +}
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +4 -0
@@ -13,8 +13,12 @@ DIRNAME=`dirname $0` ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'` [ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS +FUNCTIONS_FILE="${ROOT_DIR}`readlink -f ${ROOT_DIR}/etc/init.d/functions`" +. $FUNCTIONS_FILE # When running populate-volatile.sh at rootfs time, disable cache. [ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no +# Determine whether the rootfs is read-only +ROOTFS_READ_ONLY=`is_rootfs_readonly` # If rootfs is read-only, disable cache. [ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +3 -1
@@ -1,6 +1,8 @@ #!/bin/sh -. /etc/default/rcS +. /etc/init.d/functions + +ROOTFS_READ_ONLY=`is_rootfs_readonly` [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
meta/recipes-core/sysvinit/sysvinit/rcS-default +0 -4
@@ -23,7 +23,3 @@ FSCKFIX=yes #TICKADJ=10000 # Enable caching in populate-volatile.sh VOLATILE_ENABLE_CACHE=yes -# Indicate whether the rootfs is intended to be read-only or not. -# Setting ROOTFS_READ_ONLY to yes and rebooting will give you a read-only rootfs. -# Normally you should not change this value. -ROOTFS_READ_ONLY=no
meta/recipes-core/udev/udev/init +5 -0
@@ -79,6 +79,11 @@ case "$1" in echo "$NEWDATA" > /dev/shm/udev.cache fi else + # Determine whether the rootfs is read-only or not + ROOTFS_READ_ONLY="no" + for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do + [ "$flag" = "ro" ] && ROOTFS_READ_ONLY="yes" + done if [ "$ROOTFS_READ_ONLY" != "yes" ]; then # If rootfs is not read-only, it's possible that a new udev cache would be generated; # otherwise, we do not bother to read files.
meta/recipes-core/udev/udev/udev-cache +5 -0
@@ -18,6 +18,11 @@ export TZ=/etc/localtime [ -f /etc/default/rcS ] && . /etc/default/rcS [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache +ROOTFS_READ_ONLY="no" +for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do + [ "$flag" = "ro" ] && ROOTFS_READ_ONLY="yes" +done + if [ "$ROOTFS_READ_ONLY" = "yes" ]; then [ "$VERBOSE" != "no" ] && echo "udev-cache: read-only rootfs, skip generating udev-cache" exit 0
meta/recipes-extended/lsb/lsbinitscripts/0001-add-is_rootfs_readonly-to-functions.patch new file +37 -0
@@ -0,0 +1,37 @@ +From b8e8e7f93aca54561cc1d7945ef3ec7aca5f6f43 Mon Sep 17 00:00:00 2001 +From: Chen Qi <[email protected]> +Date: Tue, 23 Jul 2013 10:48:32 +0800 +Subject: [PATCH V2] add is_rootfs_readonly to functions + +--- + rc.d/init.d/functions | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions +index a5b2b9e..0663c7f 100644 +--- a/rc.d/init.d/functions ++++ b/rc.d/init.d/functions +@@ -577,6 +577,20 @@ apply_sysctl() { + fi + } + ++# Determine whether rootfs is read-only or not according to /proc/mounts or /etc/fstab. ++is_rootfs_readonly () { ++ local DIRNAME=`dirname $0` ++ local ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'` ++ local criteria_file ++ [ -n "$ROOT_DIR" ] && criteria_file="$ROOT_DIR/etc/fstab" || criteria_file="/proc/mounts" ++ local flag ++ for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' < $criteria_file`; do ++ [ "$flag" = "ro" ] && { echo "yes"; return 0; } ++ done ++ echo "no" ++ return 0 ++} ++ + # A sed expression to filter out the files that is_ignored_file recognizes + __sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d' + +-- +1.7.9.5 +
meta/recipes-extended/lsb/lsbinitscripts_9.48.bb +1 -0
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=ebf4e8b49780ab187d51bd26aaa022c6" S="${WORKDIR}/initscripts-${PV}" SRC_URI = "http://pkgs.fedoraproject.org/repo/pkgs/initscripts/initscripts-9.48.tar.bz2/7dfab81a5a8d3f0dea5ba55e391c26f3/initscripts-9.48.tar.bz2 \ file://functions.patch \ + file://0001-add-is_rootfs_readonly-to-functions.patch \ " SRC_URI[md5sum] = "7dfab81a5a8d3f0dea5ba55e391c26f3"
Signature · 1 line
1.7.9.5
PATCH v2 3/10 udev: remove implicit dependency on initscripts
In reply to [email protected]From: Chen Qi <[email protected]>
At some point, the udev was modified to source the functions from initscripts or lsbinitscripts. This dependency is actually not needed. If we use udev in a system where initscripts from oe-core is not available, there will be errors.
This patch fixes this problem by removing the implicit dependency.
[YOCTO #4882]
[YOCTO #4103]
--- meta/recipes-core/udev/udev/init | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
meta/recipes-core/udev/udev/init +12 -4
@@ -9,8 +9,6 @@ # Short-Description: Start udevd, populate /dev and load drivers. ### END INIT INFO -. /etc/init.d/functions - export TZ=/etc/localtime [ -d /sys/class ] || exit 1
@@ -31,6 +29,11 @@ readfiles () { done } +kill_udevd () { + pid=`pidof -x udevd` + [ -n "$pid" ] && kill $pid +} + case "$1" in start) export ACTION=add
@@ -94,7 +97,7 @@ case "$1" in fi # make_extra_nodes - killproc udevd > "/dev/null" 2>&1 + kill_udevd > "/dev/null" 2>&1 # trigger the sorted events echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
@@ -119,7 +122,12 @@ case "$1" in $0 start ;; status) - status udevd + pid=`pidof -x udevd` + if [ -n "$pid" ]; then + echo "udevd (pid $pid) is running ..." + else + echo "udevd is stopped" + fi ;; *) echo "Usage: $0 {start|stop|status|restart}"
Signature · 1 line
1.7.9.5
PATCH v2 4/10 populate-volatile.sh: use $ROOT_DIR/var/volatile/tmp as TMPDIR
In reply to [email protected]From: Chen Qi <[email protected]>
It's possible that a 'No such directory' error occurs when doing check_requirement in populate-volatile.sh at rootfs time. This is because the $ROOT_DIR/var/tmp might be a dead link.
Use $ROOT_DIR/var/volatile/tmp as the TMPDIR instead to avoid this error.
[YOCTO #4883]
[YOCTO #4103]
--- .../initscripts-1.0/populate-volatile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +1 -1
@@ -23,7 +23,7 @@ ROOTFS_READ_ONLY=`is_rootfs_readonly` [ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no CFGDIR="${ROOT_DIR}/etc/default/volatiles" -TMPROOT="${ROOT_DIR}/var/tmp" +TMPROOT="${ROOT_DIR}/var/volatile/tmp" COREDEF="00_core" [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
Signature · 1 line
1.7.9.5
PATCH v2 5/10 populate-volatile.sh: don't spawn background process at rootfs time
In reply to [email protected]From: Chen Qi <[email protected]>
If we're building a read-only rootfs, we'll get the following error now and then.
tar: .: file changed as we read it
The root cause is that we spawn background process at rootfs time. When the tar command is running, it's possible that files under rootfs are changed by background processes, thus this error.
[YOCTO #4937]
--- .../initscripts-1.0/populate-volatile.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +3 -3
@@ -46,7 +46,7 @@ create_file() { # but these failures should not be logged to make sure the do_rootfs # process doesn't fail. This does no harm, as this script will # run on target to set up the correct files and directories. - eval $EXEC > /dev/null 2>&1 & + eval $EXEC > /dev/null 2>&1 fi } }
@@ -91,7 +91,7 @@ link_file() { else # For the same reason with create_file(), failures should # not be logged. - eval $EXEC > /dev/null 2>&1 & + eval $EXEC > /dev/null 2>&1 fi }
@@ -160,7 +160,7 @@ apply_cfgfile() { [ "${TTYPE}" = "l" ] && { TSOURCE="$TLTARGET" [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." - link_file "${TSOURCE}" "${TNAME}" & + link_file "${TSOURCE}" "${TNAME}" continue }
Signature · 1 line
1.7.9.5
PATCH v2 6/10 runqemu-internal: fix to start X correctly in live images
In reply to [email protected]From: Chen Qi <[email protected]>
The QEMUOPTIONS for ISOFS was not complete, leading to failures when trying to start X in live images.
This patch fixes this problem.
[YOCTO #4103]
[YOCTO #4884]
--- scripts/runqemu-internal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runqemu-internal +1 -1
@@ -526,7 +526,7 @@ if [ "x$RAMFS" = "xtrue" ]; then fi if [ "x$ISOFS" = "xtrue" ]; then - QEMUOPTIONS="-cdrom $ROOTFS" + QEMUOPTIONS="$QEMU_NETWORK_CMD -cdrom $ROOTFS $QEMU_UI_OPTIONS" fi if [ "x$QEMUOPTIONS" = "x" ]; then
Signature · 1 line
1.7.9.5
PATCH v2 7/10 initscripts: use a uniform way to handle directories in read-only rootfs
In reply to [email protected]From: Chen Qi <[email protected]>
Packages in our system may need to write to some directories to function correctly. In read-only rootfs, these directories should be made writable.
This patch uses a convenient and uniform way to handle such situations. The read-only-rootfs-hook.sh script searches the /etc/default/readonly diretory for config files and then apply them one by one.
The config files simply have the following format. <original diretory> <corresponding directory in volatile story>
For example, /etc/default/readonly/initscripts have the following content. /var/lib /var/volatile/lib
This patch only has effect for systems with read-only rootfs.
[YOCTO #4103]
[YOCTO #4888]
--- .../initscripts-1.0/read-only-rootfs-hook.sh | 43 ++++++++++++++++++-- meta/recipes-core/initscripts/initscripts_1.0.bb | 5 +++ 2 files changed, 44 insertions(+), 4 deletions(-)
meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh +39 -4
@@ -1,15 +1,50 @@ #!/bin/sh . /etc/init.d/functions +READONLY_CFGDIR="/etc/default/readonly" ROOTFS_READ_ONLY=`is_rootfs_readonly` [ "$ROOTFS_READ_ONLY" = "no" ] && exit 0 +is_on_read_only_partition () { + DIRECTORY=$1 + dir=`readlink -f $DIRECTORY` + while true; do + if [ ! -d "$dir" ]; then + echo "ERROR: $dir is not a directory" + exit 1 + else + for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do + [ "$flag" = "FOUND" ] && partition="read-write" + [ "$flag" = "ro" ] && { partition="read-only"; break; } + done + fi + if [ "$dir" = "/" -o -n "$partition" ]; then + break + else + dir=`dirname $dir` + fi + done + [ "$partition" = "read-only" ] && echo "yes" || echo "no" +} + +apply_conf () { + cfgfile=$1 + cat $cfgfile | while read line; do + eval `echo "$line" | sed -n "s/\(.*\)\ \(.*\)/DIR_READONLY=\1; DIR_VOLATILE=\2;/p"` + if [ `is_on_read_only_partition $DIR_READONLY` = "yes" ]; then + mkdir -p $DIR_VOLATILE + cp -a $DIR_READONLY/* $DIR_VOLATILE + mount --bind $DIR_VOLATILE $DIR_READONLY + fi + done +} + 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 + grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile + for file in `ls -1 "$READONLY_CFGDIR"`; do + apply_conf "$READONLY_CFGDIR/$file" + done fi
meta/recipes-core/initscripts/initscripts_1.0.bb +5 -0
@@ -105,6 +105,11 @@ do_install () { install -m 0755 ${WORKDIR}/umountfs ${D}${sysconfdir}/init.d/umountfs install -m 0755 ${WORKDIR}/device_table.txt ${D}${sysconfdir}/device_table # +# Create config files for read-only rootfs +# + install -d ${D}${sysconfdir}/default/readonly + echo "/var/lib /var/volatile/lib" > ${D}${sysconfdir}/default/readonly/initscripts +# # Create runlevel links # update-rc.d -r ${D} rmnologin.sh start 99 2 3 4 5 .
Signature · 1 line
1.7.9.5
PATCH v2 8/10 irda-utils: make /etc/sysconfig writable in read-only rootfs
In reply to [email protected]From: Chen Qi <[email protected]>
This diretory needs to be writable, the following error will appear at system start-up.
/etc/rc5.d/S20irattach: /etc/sysconfig/irda: Read-only file system
[YOCTO #4103]
[YOCTO #4886]
--- .../irda-utils/irda-utils_0.9.18.bb | 4 ++++ 1 file changed, 4 insertions(+)
meta/recipes-connectivity/irda-utils/irda-utils_0.9.18.bb +4 -0
@@ -37,4 +37,8 @@ do_install () { install -d ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME} + + # Create config files for read-only rootfs + install -d ${D}${sysconfdir}/default/readonly + echo "/etc/sysconfig /var/volatile/etc/sysconfig" > ${D}${sysconfdir}/default/readonly/irda-utils }
Signature · 1 line
1.7.9.5
PATCH v2 9/10 lighttpd: make /www diretory writable in read-only rootfs
In reply to [email protected]From: Chen Qi <[email protected]>
This directory needs to be writable for system to work correctly.
[YOCTO #4103]
[YOCTO #4885]
--- meta/recipes-extended/lighttpd/lighttpd_1.4.32.bb | 3 +++ 1 file changed, 3 insertions(+)
meta/recipes-extended/lighttpd/lighttpd_1.4.32.bb +3 -0
@@ -49,6 +49,9 @@ do_install_append() { install -m 0755 ${WORKDIR}/lighttpd ${D}${sysconfdir}/init.d install -m 0755 ${WORKDIR}/lighttpd.conf ${D}${sysconfdir} install -m 0644 ${WORKDIR}/index.html.lighttpd ${D}/www/pages/index.html + # Create config files for read-only rootfs + install -d ${D}${sysconfdir}/default/readonly + echo "/www /var/volatile/www" > ${D}${sysconfdir}/default/readonly/lighttpd } FILES_${PN} += "${sysconfdir} /www"
Signature · 1 line
1.7.9.5
PATCH v2 10/10 openssh: make /etc/ssh directory writable in read-only rootfs
In reply to [email protected]From: Chen Qi <[email protected]>
If the rootfs is read-only and the ssh keys are not available at system start-up, the init script will generate ssh keys into /etc/ssh, thus causing a 'read-only file system' error.
Make this directory writable in case of a read-only rootfs. Note that if the ssh keys are pregenerated, they will not be lost, as there's a copying process before bind mounting.
[YOCTO #4887]
--- meta/recipes-connectivity/openssh/openssh_6.2p2.bb | 3 +++ 1 file changed, 3 insertions(+)
meta/recipes-connectivity/openssh/openssh_6.2p2.bb +3 -0
@@ -86,6 +86,9 @@ do_install_append () { install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/sshd rm -f ${D}${bindir}/slogin ${D}${datadir}/Ssh.bin rmdir ${D}${localstatedir}/run/sshd ${D}${localstatedir}/run ${D}${localstatedir} + # Create config files for read-only rootfs + install -d ${D}${sysconfdir}/default/readonly + echo "/etc/ssh /var/volatile/etc/ssh" > ${D}${sysconfdir}/default/readonly/openssh } ALLOW_EMPTY_${PN} = "1"
Signature · 1 line
1.7.9.5
Re: [PATCH V2 08/10] irda-utils: make /etc/sysconfig writable in read-only rootfs
In reply to [email protected]Quoted 6 lines · On Mon, 2013-07-29 at 10:33 +0800, [email protected] wrote:
From: Chen Qi <[email protected]>
This diretory needs to be writable, the following error will appear at system start-up.
/etc/rc5.d/S20irattach:/etc/sysconfig/irda: Read-only file system
The whole chunk of code in that script that's trying to write to /etc/sysconfig seems bogus. I think the right fix is just to delete it rather than trying to provide a a volatile implementation of /etc/sysconfig (which seems like a contradiction in terms).
p.
Re: [PATCH V2 09/10] lighttpd: make /www diretory writable in read-only rootfs
In reply to [email protected]Quoted 1 line · On 29 July 2013 03:33, <[email protected]> wrote:
+ echo "/www
/var/volatile/www" > ${D}${sysconfdir}/default/readonly/lighttpd
/www is the default lighttpd document root, where the web sites are stored, so putting them in a tmpfs would be very wrong indeed.
Why does lightttp need write access? If it's putting logs in there then they should be in /var/log, PIDs in /run and so on.
Ross
Re: [PATCH V2 10/10] openssh: make /etc/ssh directory writable in read-only rootfs
In reply to [email protected]Quoted 9 lines · On 29 July 2013 03:33, <[email protected]> wrote:
From: Chen Qi <[email protected]>
If the rootfs is read-only and the ssh keys are not available at system start-up, the init script will generate ssh keys into
/etc/ssh, thus causing a 'read-only file system' error.Make this directory writable in case of a read-only rootfs. Note that if the ssh keys are pregenerated, they will not be lost, as there's a copying process before bind mounting.
I'm not very keen on the idea of every oe-core system having a tmpfs on /etc/openssh just for read-only-root configurations where there isn't a pre-generated key.
At least one better option would be to handle the read-only / with no pre-generated keys situation in the init script, and write keys to /run.
Ross
Re: [PATCH V2 10/10] openssh: make /etc/ssh directory writable in read-only rootfs
Quoted 7 lines · Ross
Quoted 6 lines · On 29 July 2013 03:33, <[email protected]> wrote:
From: Chen Qi <[email protected]>
If the rootfs is read-only and the ssh keys are not available at system start-up, the init script will generate ssh keys into
/etc/ssh, thus causing a 'read-only file system' error.
Quoted 5 lines
Quoted 3 lines
Make this directory writable in case of a read-only rootfs. Note that if the ssh keys are pregenerated, they will not be lost, as there's a copying process before bind mounting.
I'm not very keen on the idea of every oe-core system having a tmpfs on
/etc/opensshjust for read-only-root configurations
I agree, especially when the configuration is not likely to change at runtime.
Quoted 6 lines
where there
isn't a pre-generated key.At least one better option would be to handle the read-only / with no pre-generated keys situation in the init script, and write keys to /run.
For now, I want to use the following logic.
If the rootfs is not read-only, everything remains the same as before.
If the rootfs is read-only and there are pre-generated keys under /etc/ssh, we use the pre-generated keys. The pre-generated keys are mainly for debugging or development purpose.
If the rootfs is read-only and there are no pre-generated keys under /etc/ssh, we use /var/run/ssh as the location for ssh keys. That is, at system boot-up, the generated ssh keys will be put into /var/run/ssh.
What do you think about it? If it's OK, I'll send out a V3.
Best Regards,
Chen Qi
Re: [PATCH V2 09/10] lighttpd: make /www diretory writable in read-only rootfs
In reply to Burton, RossQuoted 6 lines · Ross
Quoted 1 line · On 29 July 2013 03:33, <[email protected]> wrote:
+ echo "/www
/var/volatile/www" > ${D}${sysconfdir}/default/readonly/lighttpd/www is the default lighttpd document root, where the web sites are stored, so putting them in a tmpfs would be very wrong indeed.
Why does lightttp need write access? If it's putting logs in there
Yes. Exactly the log issue.
After some thinking, I think I'll just drop this patch.
Because even if I move the log location to /var/log/xxx, it will not make the situation any better, as the /www directory is still not writable. So I think, at this point, we should not do too much.
I'll assume that if the user is using a read-only rootfs and his system is holding a website, maybe he'll just mount some writable media to /www.
Best Regards,
Chen Qi
Quoted 5 lines
then they should be in
/var/log, PIDs in /run and so on.Ross
Re: [PATCH V2 08/10] irda-utils: make /etc/sysconfig writable in read-only rootfs
In reply to Phil BlundellQuoted 6 lines · Phil Blundell
Quoted 5 lines · On Mon, 2013-07-29 at 10:33 +0800, [email protected] wrote:
From: Chen Qi <[email protected]>
This diretory needs to be writable, the following error will appear at system start-up.
Quoted 9 lines
Quoted 1 line
/etc/rc5.d/S20irattach:/etc/sysconfig/irda: Read-only file systemThe whole chunk of code in that script that's trying to write to
/etc/sysconfigseems bogus. I think the right fix is just to delete it rather than trying to provide a a volatile implementation of/etc/sysconfig(which seems like a contradiction in terms).p.
After a second look at the script, I think you're right. Thank your for pointing it out :)
I'll fix this in my V3 patchset.
Best Regards,
Chen Qi