Ninjatrappeur's systemd working tree
Go to file
Eric DeVolder 9b4abc69b2 pstore: Tool to archive contents of pstore
This patch introduces the systemd pstore service which will archive the
contents of the Linux persistent storage filesystem, pstore, to other storage,
thus preserving the existing information contained in the pstore, and clearing
pstore storage for future error events.

Linux provides a persistent storage file system, pstore[1], that can store
error records when the kernel dies (or reboots or powers-off). These records in
turn can be referenced to debug kernel problems (currently the kernel stuffs
the tail of the dmesg, which also contains a stack backtrace, into pstore).

The pstore file system supports a variety of backends that map onto persistent
storage, such as the ACPI ERST[2, Section 18.5 Error Serialization] and UEFI
variables[3 Appendix N Common Platform Error Record]. The pstore backends
typically offer a relatively small amount of persistent storage, e.g. 64KiB,
which can quickly fill up and thus prevent subsequent kernel crashes from
recording errors. Thus there is a need to monitor and extract the pstore
contents so that future kernel problems can also record information in the
pstore.

The pstore service is independent of the kdump service. In cloud environments
specifically, host and guest filesystems are on remote filesystems (eg. iSCSI
or NFS), thus kdump relies [implicitly and/or explicitly] upon proper operation
of networking software *and* hardware *and* infrastructure.  Thus it may not be
possible to capture a kernel coredump to a file since writes over the network
may not be possible.

The pstore backend, on the other hand, is completely local and provides a path
to store error records which will survive a reboot and aid in post-mortem
debugging.

Usage Notes:
This tool moves files from /sys/fs/pstore into /var/lib/systemd/pstore.

To enable kernel recording of error records into pstore, one must either pass
crash_kexec_post_notifiers[4] to the kernel command line or enable via 'echo Y
 > /sys/module/kernel/parameters/crash_kexec_post_notifiers'. This option
invokes the recording of errors into pstore *before* an attempt to kexec/kdump
on a kernel crash.

Optionally, to record reboots and shutdowns in the pstore, one can either pass
the printk.always_kmsg_dump[4] to the kernel command line or enable via 'echo Y >
/sys/module/printk/parameters/always_kmsg_dump'. This option enables code on the
shutdown path to record information via pstore.

This pstore service is a oneshot service. When run, the service invokes
systemd-pstore which is a tool that performs the following:
 - reads the pstore.conf configuration file
 - collects the lists of files in the pstore (eg. /sys/fs/pstore)
 - for certain file types (eg. dmesg) a handler is invoked
 - for all other files, the file is moved from pstore

 - In the case of dmesg handler, final processing occurs as such:
   - files processed in reverse lexigraphical order to faciliate
     reconstruction of original dmesg
   - the filename is examined to determine which dmesg it is a part
   - the file is appended to the reconstructed dmesg

For example, the following pstore contents:

 root@vm356:~# ls -al /sys/fs/pstore
 total 0
 drwxr-x--- 2 root root    0 May  9 09:50 .
 drwxr-xr-x 7 root root    0 May  9 09:50 ..
 -r--r--r-- 1 root root 1610 May  9 09:49 dmesg-efi-155741337601001
 -r--r--r-- 1 root root 1778 May  9 09:49 dmesg-efi-155741337602001
 -r--r--r-- 1 root root 1726 May  9 09:49 dmesg-efi-155741337603001
 -r--r--r-- 1 root root 1746 May  9 09:49 dmesg-efi-155741337604001
 -r--r--r-- 1 root root 1686 May  9 09:49 dmesg-efi-155741337605001
 -r--r--r-- 1 root root 1690 May  9 09:49 dmesg-efi-155741337606001
 -r--r--r-- 1 root root 1775 May  9 09:49 dmesg-efi-155741337607001
 -r--r--r-- 1 root root 1811 May  9 09:49 dmesg-efi-155741337608001
 -r--r--r-- 1 root root 1817 May  9 09:49 dmesg-efi-155741337609001
 -r--r--r-- 1 root root 1795 May  9 09:49 dmesg-efi-155741337710001
 -r--r--r-- 1 root root 1770 May  9 09:49 dmesg-efi-155741337711001
 -r--r--r-- 1 root root 1796 May  9 09:49 dmesg-efi-155741337712001
 -r--r--r-- 1 root root 1787 May  9 09:49 dmesg-efi-155741337713001
 -r--r--r-- 1 root root 1808 May  9 09:49 dmesg-efi-155741337714001
 -r--r--r-- 1 root root 1754 May  9 09:49 dmesg-efi-155741337715001

results in the following:

 root@vm356:~# ls -al /var/lib/systemd/pstore/155741337/
 total 92
 drwxr-xr-x 2 root root  4096 May  9 09:50 .
 drwxr-xr-x 4 root root    40 May  9 09:50 ..
 -rw-r--r-- 1 root root  1610 May  9 09:50 dmesg-efi-155741337601001
 -rw-r--r-- 1 root root  1778 May  9 09:50 dmesg-efi-155741337602001
 -rw-r--r-- 1 root root  1726 May  9 09:50 dmesg-efi-155741337603001
 -rw-r--r-- 1 root root  1746 May  9 09:50 dmesg-efi-155741337604001
 -rw-r--r-- 1 root root  1686 May  9 09:50 dmesg-efi-155741337605001
 -rw-r--r-- 1 root root  1690 May  9 09:50 dmesg-efi-155741337606001
 -rw-r--r-- 1 root root  1775 May  9 09:50 dmesg-efi-155741337607001
 -rw-r--r-- 1 root root  1811 May  9 09:50 dmesg-efi-155741337608001
 -rw-r--r-- 1 root root  1817 May  9 09:50 dmesg-efi-155741337609001
 -rw-r--r-- 1 root root  1795 May  9 09:50 dmesg-efi-155741337710001
 -rw-r--r-- 1 root root  1770 May  9 09:50 dmesg-efi-155741337711001
 -rw-r--r-- 1 root root  1796 May  9 09:50 dmesg-efi-155741337712001
 -rw-r--r-- 1 root root  1787 May  9 09:50 dmesg-efi-155741337713001
 -rw-r--r-- 1 root root  1808 May  9 09:50 dmesg-efi-155741337714001
 -rw-r--r-- 1 root root  1754 May  9 09:50 dmesg-efi-155741337715001
 -rw-r--r-- 1 root root 26754 May  9 09:50 dmesg.txt

where dmesg.txt is reconstructed from the group of related
dmesg-efi-155741337* files.

Configuration file:
The pstore.conf configuration file has four settings, described below.
 - Storage : one of "none", "external", or "journal". With "none", this
   tool leaves the contents of pstore untouched. With "external", the
   contents of the pstore are moved into the /var/lib/systemd/pstore,
   as well as logged into the journal.  With "journal", the contents of
   the pstore are recorded only in the systemd journal. The default is
   "external".
 - Unlink : is a boolean. When "true", the default, then files in the
   pstore are removed once processed. When "false", processing of the
   pstore occurs normally, but the pstore files remain.

References:
[1] "Persistent storage for a kernel's dying breath",
    March 23, 2011.
    https://lwn.net/Articles/434821/

[2] "Advanced Configuration and Power Interface Specification",
    version 6.2, May 2017.
    https://www.uefi.org/sites/default/files/resources/ACPI_6_2.pdf

[3] "Unified Extensible Firmware Interface Specification",
    version 2.8, March 2019.
    https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf

[4] "The kernel’s command-line parameters",
    https://static.lwn.net/kerneldoc/admin-guide/kernel-parameters.html
2019-07-19 21:46:07 +02:00
.github FUNDING: this needs to be yaml 2019-07-08 16:55:31 +02:00
.lgtm/cpp-queries lgtm: complain about accept() [people should use accept4() instead, due to O_CLOEXEC] 2019-04-10 20:03:38 +02:00
.mkosi mkosi: update to Fedora30 (#12642) 2019-05-23 09:39:07 +02:00
catalog catalog: reference ExecCondition= in unit skipped str 2019-07-17 22:43:05 -07:00
coccinelle tree-wide: use empty-to-root a bit more 2019-07-16 12:40:22 +02:00
docs core: ExecCondition= for services 2019-07-17 11:35:02 +02:00
factory/etc factory: include pam_keyinit.so in PAM factory configuration 2019-07-13 11:06:24 +02:00
hwdb Add accel mount matrix for Irbis TW90 2019-07-08 11:53:34 +02:00
man pstore: Tool to archive contents of pstore 2019-07-19 21:46:07 +02:00
modprobe.d Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
network udev,network: warn when .link or .network file has no [Match] section 2019-04-25 08:41:10 +02:00
po po: Fix typo in German translation 2019-07-14 00:07:40 +02:00
presets Drop my copyright headers 2018-06-14 13:03:20 +02:00
rules rules: enable hardware-related targets also for user instances 2019-05-28 14:18:11 +02:00
semaphoreci semaphore: avoid running autopkgtest with --apt-upgrade 2019-07-13 01:40:51 +03:00
shell-completion bash-completion: support ntp-servers and revert command for timedatectl 2019-07-17 06:59:12 +09:00
src pstore: Tool to archive contents of pstore 2019-07-19 21:46:07 +02:00
sysctl.d coredump: rely on /proc exclusively to get the name of the crashing process 2019-06-26 11:17:23 +02:00
sysusers.d sysusers,tmpfiles: re-create systemd-network, systemd-resolve and systemd-timesync 2018-07-16 17:11:50 +02:00
test Merge pull request #13070 from yuwata/network-set-route-to-dhcp-dns 2019-07-19 09:35:22 +02:00
tmpfiles.d coredump: fixed bug - some coredump temp files could be lost 2019-05-31 12:57:35 +02:00
tools meson: update hint in man/rules/ 2019-07-19 07:09:34 +09:00
travis-ci Free up some resources on Azure Pipelines 2019-07-17 13:28:38 +09:00
units pstore: Tool to archive contents of pstore 2019-07-19 21:46:07 +02:00
xorg scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.ctags editors: Prevent ctags from following symlinks 2019-02-15 11:01:20 -08:00
.dir-locals.el scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.editorconfig scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.gitattributes git: indicate that tabs are never OK in the systemd tree 2013-10-30 02:25:38 +01:00
.gitignore gitignore: add nspawn image lock and mkosi temporary files 2018-09-07 20:00:22 +02:00
.lgtm.yml lgtm: use python3 2018-12-10 03:07:17 +09:00
.mailmap update .mailmap 2019-04-02 17:31:00 +02:00
.travis.yml coverity: stop setting _Float* 2019-06-21 18:27:35 +03:00
.vimrc scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
.ycm_extra_conf.py ycm: add doc string for all the functions in configuration file 2017-11-29 13:21:49 -07:00
LICENSE.GPL2 relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
LICENSE.LGPL2.1 licence: remove references to old FSF address 2012-12-17 11:41:31 +01:00
Makefile build-sys: Fix Makefile wrapper for install target (#6548) 2017-08-07 11:29:20 +02:00
NEWS NEWS: bullet point for ExecCondition= 2019-07-17 22:27:57 -07:00
README codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
README.md Continuous Fuzzing Integration with Fuzzit 2019-06-14 21:09:40 +03:00
TODO core: ExecCondition= for services 2019-07-17 11:35:02 +02:00
azure-pipelines.yml Free up some resources on Azure Pipelines 2019-07-17 13:28:38 +09:00
configure build-sys: add basic support for ./configure && make && make install 2017-07-18 10:05:06 -04:00
fuzzbuzz.yaml fuzzbuzz: rename fuzz.yaml to fuzzbuzz.yaml 2019-07-10 05:11:52 +03:00
meson.build pstore: Tool to archive contents of pstore 2019-07-19 21:46:07 +02:00
meson_options.txt pstore: Tool to archive contents of pstore 2019-07-19 21:46:07 +02:00
mkosi.build mkosi: let's update the boot loader also in /efi 2019-03-01 12:41:32 +01:00
mkosi.default mkosi: create .mkosi directory 2016-10-06 11:53:58 -04:00
zanata.xml po: add basic fedora.zanata.org configuration 2018-02-19 13:56:57 +01:00

README.md

systemd - System and Service Manager

Count of open issues over time Count of open pull requests over time Semaphore CI Build Status
Coverity Scan Status
Fuzzit Status
CII Best Practices
Travis CI Build Status
Language Grade: C/C++
CentOS CI Build Status
Build Status

Details

General information about systemd can be found in the systemd Wiki.

Information about build requirements is provided in the README file.

Consult our NEWS file for information about what's new in the most recent systemd versions.

Please see the Hacking guide for information on how to hack on systemd and test your modifications.

Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.

When preparing patches for systemd, please follow our Coding Style Guidelines.

If you are looking for support, please contact our mailing list or join our IRC channel.

Stable branches with backported patches are available in the stable repo.