Write journal to persistent storage

Currently the journal is written to a RAM based
filesystem which is lost on BMC reboots. This commit
will move the journal to a persistent filesystem location
so it will be available after BMC reboots for debug.
This change is only being done by default on
witherspoon systems with this commit. Other systems
may use this as a reference if they wish to move.

By default, journald uses 10% of the filesystem
(default is /var/log/journal/) and it will ensure 15%
of the filesystem space is left free. Specific machine
configs in openbmc can override these defaults if
they wish. For witherspoon, we will use 3MB max and use
the 15% left free default.

Due to the way openbmc mounts its filesytems, a
systemd-journald.service file override is required to
ensure journald does not start until the /etc/ filesystem
is fully mounted.

journald uses /etc/machine-id to create a directory
in which it stores its journal data. journalctl uses
/etc/machine-id to know which directory to look into
when a user requests the data. Without this override,
journald will end up making a random machine-id
and using that because /etc/machine-id is not available
when systemd-journald.service is started. journalctl
looks up the /etc/machine-id when its run, so it will
use the correct one (but not the one journald is using).

Witherspoon uses the new UBI filesystem, and only
has a total of 4MB available within /var. Ensure the
journal only ever uses 3MB of that space to leave room
for other applications.

In testing it was found that the persistence of journald
had minor impacts to overall flash erase blocks. With
persistence enabled or disabled, it was noted that the
UBI maximum erase count value incremented by 1 for every
10-20 boots of the host. Our CI system, which gets a
lot of activity (new image flashing, REST api testing,
and host boots) average 10-12 erase counts a day. A worst
case of 15 erase blocks a day would mean 18.2 years before
hitting the 100,000 erase block limit.

Resolves openbmc/openbmc#1627

Change-Id: I30211108f26bd9cd758800f457c17ed03d13e802
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/systemd/systemd_%.bbappend b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/systemd/systemd_%.bbappend
new file mode 100644
index 0000000..b4bfc1f
--- /dev/null
+++ b/meta-openbmc-machines/meta-openpower/meta-ibm/meta-witherspoon/recipes-phosphor/systemd/systemd_%.bbappend
@@ -0,0 +1,14 @@
+FILESEXTRAPATHS_append := "${THISDIR}/${PN}:"
+SRC_URI += "file://journald-storage-policy.conf"
+SRC_URI += "file://systemd-journald-override.conf"
+SRC_URI += "file://journald-size-policy.conf"
+
+FILES_${PN} += "${libdir}/systemd/journald.conf.d/journald-storage-policy.conf"
+FILES_${PN} += "${systemd_system_unitdir}/systemd-journald.service.d/systemd-journald-override.conf"
+FILES_${PN} += "${libdir}/systemd/journald.conf.d/journald-size-policy.conf"
+
+do_install_append() {
+        install -m 644 -D ${WORKDIR}/journald-storage-policy.conf ${D}${libdir}/systemd/journald.conf.d/journald-storage-policy.conf
+        install -m 644 -D ${WORKDIR}/systemd-journald-override.conf ${D}${systemd_system_unitdir}/systemd-journald.service.d/systemd-journald-override.conf
+        install -m 644 -D ${WORKDIR}/journald-size-policy.conf ${D}${libdir}/systemd/journald.conf.d/journald-size-policy.conf
+}