Saving the journal is a good idea - it has some log info that aren't in
our existing logs (dracut output, for example).
We could just make a copy of it at the end of the install.. but we can
also make the running journald move the active journal to the disk, by:
1) creating /var/log/journal (as a symlink to the disk), and
2) (re)starting systemd-journal-flush.service.
Doing it this way rather than copying it at the end saves some RAM and
gives us on-disk logs that will be there even if you yank the power cord
before we get to kickstart %post.
So: as soon as we're sure we've got somewhere persistent we can write to,
we should move the journal. At the moment where preInstall happens we
have the target disk mounted but there's nothing on it yet. This is
probably the earliest point where we can safely start writing to disk,
so that's when it happens.
---
pyanaconda/iutil.py | 6 ++++++
pyanaconda/packaging/__init__.py | 1 +
2 files changed, 7 insertions(+)
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py
index bd6e048..532aeb3 100644
--- a/pyanaconda/iutil.py
+++ b/pyanaconda/iutil.py
@@ -530,3 +530,9 @@ def strip_accents(s):
"""
return ''.join((c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn'))
+
+def move_journal_to_disk():
+ log.info("moving journal to disk")
+ mkdirChain(ROOT_PATH+"/var/log/anaconda/journal")
+ os.symlink(ROOT_PATH+"/var/log/anaconda/journal",
"/var/log/journal")
+ restart_service("systemd-journal-flush")
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index cba0f79..961a819 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -487,6 +487,7 @@ class Payload(object):
def preInstall(self, packages=None, groups=None):
""" Perform pre-installation tasks. """
iutil.mkdirChain(ROOT_PATH + "/root")
+ iutil.move_journal_to_disk()
def install(self):
""" Install the payload. """
--
1.8.1.4