initscripts: Add custom mount args for /var/lib

Adds bitbake variable to set additional mount flags for the /var/lib
overlayfs or bind mount when using a read-only root filesystem. This
can be used to set additional options like "-o nodev".

(From OE-Core rev: c3109e40e2c2c881996dd3fcc95fca74f098646d)

Signed-off-by: Colin McAllister <colin.mcallister@garmin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Colin McAllister
2024-01-26 13:57:44 -06:00
committed by Richard Purdie
parent 04eac1f2b6
commit 3bb286730b
2 changed files with 4 additions and 2 deletions

View File

@@ -37,9 +37,9 @@ if [ "$1" = "start" ] ; then
mkdir -p /var/volatile/.lib-work
# Try to mount using overlay, which is much faster than copying
# files. If that fails, fallback to the slower copy
if ! mount -t overlay overlay -olowerdir=/var/lib,upperdir=/var/volatile/lib,workdir=/var/volatile/.lib-work /var/lib > /dev/null 2>&1; then
if ! mount -t overlay overlay SED_VARLIBMOUNTARGS -olowerdir=/var/lib,upperdir=/var/volatile/lib,workdir=/var/volatile/.lib-work /var/lib > /dev/null 2>&1; then
cp -a /var/lib/* /var/volatile/lib
mount --bind /var/volatile/lib /var/lib
mount SED_VARLIBMOUNTARGS --bind /var/volatile/lib /var/lib
fi
fi
fi

View File

@@ -58,10 +58,12 @@ FILES:${PN}-functions = "${sysconfdir}/init.d/functions*"
FILES:${PN}-sushell = "${base_sbindir}/sushell"
HALTARGS ?= "-d -f"
VARLIBMOUNTARGS ?= ""
do_configure() {
sed -i -e "s:SED_HALTARGS:${HALTARGS}:g" ${WORKDIR}/halt
sed -i -e "s:SED_HALTARGS:${HALTARGS}:g" ${WORKDIR}/reboot
sed -i -e "s:SED_VARLIBMOUNTARGS:${VARLIBMOUNTARGS}:g" ${WORKDIR}/read-only-rootfs-hook.sh
}
do_install () {