filesystem: mount rw and overlay
Append base-files to add new fstab and depend on mount-overlay recipe.
Add systemd services to help mounting overlay fs.
Resolves openbmc/openbmc#2134
Change-Id: Ib56fcdde9f7364fca56a08e1ce72e7cafaac35b0
Signed-off-by: Edward A. James <eajames@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-core/base-files/base-files/fstab b/meta-phosphor/common/recipes-core/base-files/base-files/fstab
new file mode 100644
index 0000000..eab105b
--- /dev/null
+++ b/meta-phosphor/common/recipes-core/base-files/base-files/fstab
@@ -0,0 +1,9 @@
+# openbmc fstab
+
+/dev/root / auto defaults 1 1
+proc /proc proc defaults 0 0
+devpts /dev/pts devpts mode=0620,gid=5 0 0
+tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
+ubi0:rwfs /var ubifs defaults 0 0
+overlay /etc overlay defaults,x-systemd.requires=prepare-overlay.service,lowerdir=/etc,upperdir=/var/persist/etc,workdir=/var/persist/etc-work 0 0
+tmpfs /var/volatile tmpfs defaults 0 0
diff --git a/meta-phosphor/common/recipes-core/base-files/base-files_%.bbappend b/meta-phosphor/common/recipes-core/base-files/base-files_%.bbappend
new file mode 100644
index 0000000..d7e7a3b
--- /dev/null
+++ b/meta-phosphor/common/recipes-core/base-files/base-files_%.bbappend
@@ -0,0 +1,5 @@
+inherit obmc-phosphor-utils
+
+FILESEXTRAPATHS_prepend := "${@mf_enabled(d, 'obmc-ubi-fs', '${THISDIR}/${PN}:')}"
+
+RDEPENDS_${PN}_append += "${@mf_enabled(d, 'obmc-ubi-fs', 'mount-overlay-help')}"
diff --git a/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help.bb b/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help.bb
new file mode 100644
index 0000000..4125fd0
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help.bb
@@ -0,0 +1,5 @@
+inherit obmc-phosphor-license
+
+SYSTEMD_SERVICE_${PN} = "prepare-overlay.service mount-machine-id.service"
+
+inherit obmc-phosphor-systemd
diff --git a/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help/mount-machine-id.service b/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help/mount-machine-id.service
new file mode 100644
index 0000000..0d72f0a
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help/mount-machine-id.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Mount machine-id
+Requires=etc.mount
+After=etc.mount
+DefaultDependencies=false
+ConditionPathExists=!/var/persist/etc/machine-id
+
+[Install]
+RequiredBy=local-fs.target
+
+[Service]
+ExecStart=/bin/sh -c "mount --bind /run/machine-id /etc/machine-id"
+Type=oneshot
+RemainAfterExit=no
diff --git a/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help/prepare-overlay.service b/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help/prepare-overlay.service
new file mode 100644
index 0000000..0f48277
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/mount-overlay-help/mount-overlay-help/prepare-overlay.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Prepare for overlay fs
+RequiresMountsFor=/var
+DefaultDependencies=false
+
+[Service]
+ExecStart=/bin/sh -c "rm -rf /var/persist/etc-work && mkdir -p /var/persist/etc /var/persist/etc-work"
+Type=oneshot
+RemainAfterExit=no