-
Notifications
You must be signed in to change notification settings - Fork 882
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta-phosphor: add phosphor-static-norootfs-init recipe
There are two existing recipes for early mounting procedures: * preinit-mounts - for obmc-ubi-fs * phosphor-mmc-init - for phosphor-mmc Add one for the static-norootfs image type. This one is similar to the preinit-mounts, except for it mounts /var as an overlay to avoid violating FHS expectations (See #3658 as an example of why this is problematic). I did not directly change preinit-mounts and fix it because there are likely field upgrade issues in doing this for existing users. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I62ab288c2d139cfecadeb191d576e2753120e123
- Loading branch information
1 parent
139d2d6
commit d91b4b3
Showing
7 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
SUMMARY = "Phosphor OpenBMC pre-init scripts for static-norootfs layout" | ||
DESCRIPTION = "Phosphor OpenBMC filesystem mount implementation for static-norootfs" | ||
LICENSE = "Apache-2.0" | ||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" | ||
PR = "r1" | ||
|
||
SOURCE_FILES = "\ | ||
init \ | ||
10-early-mounts \ | ||
20-udev \ | ||
30-ubiattach-or-format \ | ||
50-mount-persistent \ | ||
" | ||
SRC_URI += "\ | ||
${@' '.join(\ | ||
[ 'file://' + x for x in d.getVar('SOURCE_FILES', True).split()])} \ | ||
" | ||
|
||
S = "${WORKDIR}" | ||
|
||
inherit allarch | ||
inherit update-alternatives | ||
|
||
PKG_INSTALL_DIR="${libexecdir}/${BPN}" | ||
FILES:${PN} += "${PKG_INSTALL_DIR}" | ||
|
||
do_install() { | ||
install -d ${D}${PKG_INSTALL_DIR} | ||
|
||
for f in ${SOURCE_FILES} ; do | ||
install -m 0755 ${S}/$f ${D}${PKG_INSTALL_DIR}/$f | ||
done | ||
} | ||
|
||
RDEPENDS:${PN} += " \ | ||
${VIRTUAL-RUNTIME_base-utils} \ | ||
mtd-utils-ubifs \ | ||
udev \ | ||
" | ||
|
||
ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init" | ||
# Use a number higher than the systemd init alternative so that | ||
# ours is enabled instead. | ||
ALTERNATIVE_PRIORITY[init] ?= "400" | ||
|
||
ALTERNATIVE:${PN} = "init" | ||
ALTERNATIVE_TARGET[init] = "${PKG_INSTALL_DIR}/init" |
6 changes: 6 additions & 0 deletions
6
meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/10-early-mounts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
mount dev dev -tdevtmpfs | ||
mount sys sys -tsysfs | ||
mount proc proc -tproc | ||
mount tmpfs run -t tmpfs -o mode=755,nodev |
9 changes: 9 additions & 0 deletions
9
meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/20-udev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
# We need to run udevd in order to get the /dev/mtd volumes to show up. | ||
if udevd --daemon; then | ||
udevadm trigger --type=devices --action=add && \ | ||
udevadm settle --timeout=10 | ||
|
||
udevadm control --exit | ||
fi |
22 changes: 22 additions & 0 deletions
22
...sphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/30-ubiattach-or-format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
if [ ! -e /dev/mtd/rwfs ]; then | ||
exit 1 | ||
fi | ||
|
||
if ! ubiattach -p /dev/mtd/rwfs > /dev/null ; then | ||
if ! ubiformat --yes /dev/mtd/rwfs ; then | ||
exit 1 | ||
fi | ||
|
||
if ! ubiattach -p /dev/mtd/rwfs ; then | ||
exit 1 | ||
fi | ||
|
||
if ! ubimkvol /dev/ubi0 -N rwfs -m ; then | ||
exit 1 | ||
fi | ||
fi | ||
|
||
mkdir -p /run/mnt-persist | ||
mount -t ubifs ubi0:rwfs /run/mnt-persist -o sync,compr=zstd |
20 changes: 20 additions & 0 deletions
20
...phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/50-mount-persistent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
PERSIST=/run/mnt-persist | ||
|
||
if [ ! -d $PERSIST ]; then | ||
exit 0 | ||
fi | ||
|
||
for m in var etc home/root; do | ||
if [ ! -d $PERSIST/$m-data ]; then | ||
mkdir -p $PERSIST/$m-data | ||
fi | ||
|
||
if [ ! -d $PERSIST/$m-work ]; then | ||
mkdir -p $PERSIST/$m-work | ||
fi | ||
|
||
mount overlay /$m -t overlay -o \ | ||
lowerdir=/$m,upperdir=$PERSIST/$m-data,workdir=$PERSIST/$m-work | ||
done |
13 changes: 13 additions & 0 deletions
13
meta-phosphor/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
|
||
cd / | ||
|
||
for f in /usr/libexec/phosphor-static-norootfs-init/*; do | ||
if [ "$(basename "$f")" = "init" ]; then | ||
continue | ||
fi | ||
|
||
$f | ||
done | ||
|
||
exec /lib/systemd/systemd |