summaryrefslogtreecommitdiff
path: root/meta-phosphor/common/recipes-phosphor/preinit-mounts
diff options
context:
space:
mode:
authorEdward A. James <eajames@us.ibm.com>2017-11-10 01:03:14 +0300
committerAndrew Geissler <geissonator@yahoo.com>2017-11-28 16:49:42 +0300
commitc03b9c4a5d5f8e089297d8d4c13540d6b2c9421f (patch)
tree9ac113538f9b8edf3b576540c0415994c37c0aad /meta-phosphor/common/recipes-phosphor/preinit-mounts
parent8053d428ff7f353463c25447de450056d441d5bd (diff)
downloadopenbmc-c03b9c4a5d5f8e089297d8d4c13540d6b2c9421f.tar.xz
init: Add init script to setup /etc mount before starting systemd
Systemd requires /etc mounted and ready at init time. Previously, we were mounting /etc as an overlay from the persistant filesystem after systemd started. This caused a variety of issues with systemd and associated applications (journal, etc). This change also adds factory reset functionality. Resolves openbmc/openbmc#2542 Change-Id: Ib8a38e99df39f833026fe4475670a7ec2b9c8d4d Signed-off-by: Edward A. James <eajames@us.ibm.com>
Diffstat (limited to 'meta-phosphor/common/recipes-phosphor/preinit-mounts')
-rw-r--r--meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts.bb10
-rw-r--r--meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts/init19
2 files changed, 29 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts.bb b/meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts.bb
new file mode 100644
index 0000000000..e3aaf546bc
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts.bb
@@ -0,0 +1,10 @@
+inherit obmc-phosphor-license
+
+SRC_URI += "file://init"
+
+FILES_${PN} += "/sbin/init"
+
+do_install() {
+ install -d ${D}/sbin
+ install -m 0755 ${WORKDIR}/init ${D}/sbin/init
+}
diff --git a/meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts/init b/meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts/init
new file mode 100644
index 0000000000..91f8038f9e
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/preinit-mounts/preinit-mounts/init
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if ! mount ubi0:rwfs /var -t ubifs -o defaults; then
+ if ! mount ubi0:rwfs /var -t ubifs -o defaults,ro; then
+ mount tmpfs /var -t tmpfs -o defaults
+ fi
+fi
+
+mkdir -p /var/persist/etc /var/persist/etc-work /var/persist/home/root
+
+rm -rf /var/persist/etc-work/*
+# rm -rf specifically skips . and .. directories; pipe all output to null to avoid the error message
+rm -rf /var/persist/etc-work/.* > /dev/null 2>&1
+
+if ! mount overlay /etc -t overlay -o defaults,lowerdir=/etc,upperdir=/var/persist/etc,workdir=/var/persist/etc-work; then
+ mount overlay /etc -t overlay -o defaults,lowerdir=/etc:/var/persist/etc
+fi
+
+exec /lib/systemd/systemd