6f381c
From 9cc6ee46e0083bc36b53d19e14fb637f7a1542dd Mon Sep 17 00:00:00 2001
6f381c
From: Alexander Graf <graf@amazon.com>
6f381c
Date: Thu, 9 Jun 2022 16:20:43 +0200
6f381c
Subject: [PATCH] pstore: Run after modules are loaded
6f381c
6f381c
The systemd-pstore service takes pstore files on boot and transfers them
6f381c
to disk. It only does it once on boot and only if it finds any. The typical
6f381c
location of the pstore on modern systems is the UEFI variable store.
6f381c
6f381c
Most distributions ship with CONFIG_EFI_VARS_PSTORE=m. That means, the
6f381c
UEFI variable store is only available on boot after the respective module
6f381c
is loaded.
6f381c
6f381c
In most situations, the pstore service gets loaded before the UEFI pstore,
6f381c
so we don't get to transfer logs. Instead, they accumulate, filling up the
6f381c
pstore over time, potentially breaking the UEFI variable store.
6f381c
6f381c
Let's add a service dependency on any kernel module that can provide a
6f381c
pstore to ensure we only scan for pstate after we can actually see pstate.
6f381c
6f381c
I have seen live occurences of systems breaking because we did not erase
6f381c
the pstates and ran out of UEFI nvram space.
6f381c
6f381c
Fixes https://github.com/systemd/systemd/issues/18540
6f381c
6f381c
(cherry picked from commit 70e74a5997ae2ce7ba72a74ac949c3b2dad1a1d6)
6f381c
6f381c
Related: #2158832
6f381c
---
6f381c
 units/systemd-pstore.service.in | 2 ++
6f381c
 1 file changed, 2 insertions(+)
6f381c
6f381c
diff --git a/units/systemd-pstore.service.in b/units/systemd-pstore.service.in
6f381c
index 8cbf264a99..1983a9738f 100644
6f381c
--- a/units/systemd-pstore.service.in
6f381c
+++ b/units/systemd-pstore.service.in
6f381c
@@ -16,6 +16,8 @@ DefaultDependencies=no
6f381c
 After=systemd-remount-fs.service
6f381c
 Conflicts=shutdown.target
6f381c
 Before=sysinit.target shutdown.target
6f381c
+After=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
6f381c
+Wants=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
6f381c
 
6f381c
 [Service]
6f381c
 Type=oneshot