The box rebooted at 03:12. You have monitoring, you have alerts, and you have a gap in the logs exactly where the answer should be. journalctl -b -1 ends mid-line, or worse, the journal was volatile and there is no previous boot at all. The oops itself was printed by the kernel after user space was already gone, into a ring buffer that lives in RAM and is cleared on the next boot.

That is the gap pstore fills. It is not a replacement for kdump, and it is not a logging system. It is a small, local, best-effort place where the kernel can leave its last few kilobytes of text before the machine goes down — and where the next boot can pick them up.

This is a practical guide to the pieces: the pstore filesystem, the ramoops backend, the systemd archive service, and the knobs that decide whether you get a record or an empty directory.

What pstore actually is

pstore is a kernel filesystem with two halves:

  • Backends provide persistent storage: a reserved RAM region (ramoops), a block device (pstore/blk), EFI variables, ACPI ERST, or platform NVRAM.
  • Frontends decide what gets written: the kernel log tail (dmesg), the console log, user-space messages via /dev/pmsg0, and ftrace data.

The filesystem is normally mounted at /sys/fs/pstore. Records appear there as files:

dmesg-ramoops-0 kernel log record from ramoops console-ramoops-0 console frontend pmsg-ramoops-0 user-space messages ftrace-ramoops-0 persistent function trace dmesg-pstore-blk-0 pstore/blk backend dmesg-efi-... EFI variable backend dmesg-erst-... ACPI ERST backend 

The kernel writes these records from crash context. That matters: on panic there is no scheduling, no memory allocation, and no normal I/O path. A backend has to be simple enough to work in that state. ramoops is exactly that — a circular buffer in reserved RAM.

The trade-off is size and certainty. EFI pstore is often around 64 KiB. A ramoops region is whatever you reserve, typically 64 KiB to a few MiB. A full vmcore this is not.

Check what your kernel and distro actually enabled

Start here before changing anything:

uname -r ls -l /sys/fs/pstore mount | grep pstore # Debian/Ubuntu kernel config grep -E 'CONFIG_PSTORE|CONFIG_PSTORE_RAM|CONFIG_PSTORE_CONSOLE|CONFIG_PSTORE_PMSG|CONFIG_PSTORE_FTRACE|CONFIG_PSTORE_BLK' /boot/config-$(uname -r) 

On the Debian 13 machine I checked (kernel 6.12.118, systemd 257.13), the relevant config was:

CONFIG_PSTORE=y CONFIG_PSTORE_COMPRESS=y CONFIG_PSTORE_DEFAULT_KMSG_BYTES=10240 # CONFIG_PSTORE_CONSOLE is not set # CONFIG_PSTORE_PMSG is not set # CONFIG_PSTORE_FTRACE is not set CONFIG_PSTORE_RAM=m CONFIG_PSTORE_BLK=m CONFIG_PSTORE_BLK_MAX_REASON=2 

Two things worth noticing. First, CONFIG_PSTORE_RAM=m means the backend is the ramoops module, not built in. Second, the console, pmsg, and ftrace frontends were not enabled, even though this is a stock modern distro kernel. If you reserve a console_size zone on a kernel like this, you are spending persistent RAM on a frontend that cannot write to it.

If /sys/fs/pstore exists but ls says permission denied, that is normal: records are usually root-only. Use sudo.

Ramoops: reserve RAM that outlives a reset

Ramoops writes the kernel log into a reserved physical memory region. The region must not be handed to the allocator, or the kernel will eventually use it for something else.

There are three common ways to describe the region.

Device Tree (the normal route on ARM boards)

reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; ramoops@8f000000 { compatible = "ramoops"; reg = <0 0x8f000000 0 0x100000>; /* 1 MiB */ record-size = <0x20000>; /* 128 KiB per dmesg record */ console-size = <0x10000>; /* 64 KiB */ pmsg-size = <0x10000>; /* 64 KiB */ ecc-size = <16>; max-reason = <2>; /* panics and oopses */ }; }; 

The binding requires at least one of record-size, console-size, ftrace-size, or pmsg-size to be non-zero. Sizes are in bytes.

Module parameters

# /etc/modprobe.d/ramoops.conf options ramoops mem_address=0x8f000000 mem_size=0x100000 record_size=0x20000 console_size=0x10000 pmsg_size=0x10000 ecc=16 max_reason=2 

mem_address must point at memory your firmware or bootloader has already reserved. Do not invent an address and hope: if the region is not reserved, you can corrupt the running kernel or the driver will refuse to claim it.

Module parameters are created with mode 0400. They are readable by root and not writable at runtime — max_reason cannot be changed after the module loads, even by root. Plan it in modprobe.d or on the kernel command line.

A throwaway-VM recipe

The kernel's ramoops documentation shows a quick lab trick: tell the kernel to use only the first 128 MiB, then put ramoops at the 128 MiB boundary, outside the memory the kernel will use.

mem=128M ramoops.mem_address=0x8000000 ramoops.mem_size=0x100000 ramoops.record_size=0x20000 ramoops.ecc=1 

This throws away every byte of RAM above 128 MiB. It is fine for a disposable VM and a bad idea on a real server. Use it to prove the pipeline works, then move to a properly reserved region.

Newer kernels also support reserve_mem, which asks the kernel to reserve a named region at boot:

reserve_mem=2M:4096:oops ramoops.mem_name=oops 

The documentation is explicit that this is best-effort: the allocation may not land at the same address on every boot, so test it on your hardware before trusting it.

Sizing, without guessing

Ramoops carves the reserved region into fixed-size zones. The dmesg area is what remains after the console, pmsg, and ftrace zones. That remaining space is divided into record_size chunks, and the division floors.

Example: a 1 MiB region, 128 KiB records, 64 KiB console, 64 KiB pmsg:

1048576 - 65536 - 65536 = 917504 bytes 917504 / 131072 = 7 records exactly 

ECC does not change that count. The kernel computes the number of zones first, then reserves Reed-Solomon parity space inside each zone, so each record holds slightly less log text rather than reducing the record count. Leave slack and verify the actual file sizes after a test dump.

Other rules from the documentation and source:

  • mem_size is rounded down to a power of two.
  • Record chunks are written one by one; when the buffer is full, the oldest chunk is overwritten.
  • The record counter resets on reboot, and new dumps begin overwriting records. This is exactly why systemd-pstore archives and unlinks at boot.
  • max_reason defaults to 2, which is KMSG_DUMP_OOPS: oopses and panics. The enum is UNDEF=0, PANIC=1, OOPS=2, EMERG=3, SHUTDOWN=4, MAX=5.
  • ecc=1 is a special value meaning a 16-byte ECC buffer. Use a real byte count if you want more.
  • ECC helps when a watchdog or hard reset leaves RAM partially scrambled. It cannot resurrect a region that firmware cleared.

The other backends, briefly

pstore/blk writes to a block device or MTD device instead of reserved RAM. Configuration is in KB and must be a multiple of 4:

pstore_blk.blkdev=/dev/mmcblk0p7 pstore_blk.kmsg_size=64 best_effort=y 

It stores the same kinds of records, with names like dmesg-pstore-blk-0. It is useful on embedded systems with a dedicated small partition, but it asks the block driver to work in panic context — no allocations, no interrupts, no sleeping, no locks. Not every driver is suitable.

EFI pstore stores records in EFI variables. It is common on x86 machines and survives a full power loss, but the variable store is small and shared with boot entries. Chunking is visible in the filenames: one crash can appear as several dmesg-efi-* files.

ACPI ERST stores records in firmware error storage and exposes them as dmesg-erst-*. It is most useful on servers whose firmware already records platform errors.

systemd-pstore: archive before the buffer fills

A pstore record is only useful until the next crash overwrites it. systemd ships systemd-pstore.service, a oneshot service that runs early in boot, copies records out of /sys/fs/pstore, logs them to the journal, and (by default) unlinks them so the buffer is free again.

On Debian 13's systemd 257 unit, the conditions are worth knowing:

ConditionDirectoryNotEmpty=/sys/fs/pstore ConditionVirtualization=!container DefaultDependencies=no Before=sysinit.target shutdown.target After=modprobe@efi_pstore.service Wants=modprobe@efi_pstore.service 

So it does nothing in a container, and it does nothing when there are no records. On the host I checked, the unit was enabled by default.

Configuration lives in /etc/systemd/pstore.conf and drop-ins:

# /etc/systemd/pstore.conf.d/10-archive.conf [PStore] Storage=external Unlink=yes 
  • Storage=external (the default) copies files to /var/lib/systemd/pstore/ and logs a summary to the journal.
  • Storage=journal logs the file contents into the journal only. Useful when the root filesystem is read-only or you want one searchable copy.
  • Storage=none disables processing entirely.
  • Unlink=yes (the default) removes the record after it has been archived. If archiving fails, the file stays put.

The journal entry contains a FILE= field with the record contents. For EFI and ERST dmesg chunks, systemd reconstructs the pieces into a dmesg.txt under the archive directory.

Reading the evidence after a reboot

First, the raw records — if systemd has not already consumed them:

sudo ls -l /sys/fs/pstore sudo sed -n '1,80p' /sys/fs/pstore/dmesg-ramoops-0 

A ramoops dmesg file starts with a header line beginning with ====, followed by a timestamp and the log text. You may also see markers such as Oops#2 Part1 inserted by the pstore filesystem.

Then the archive:

sudo find /var/lib/systemd/pstore -maxdepth 4 -type f -printf '%TY-%Tm-%Td %TH:%TM %s %p\n' | sort 

EFI and ERST records are filed under subdirectories derived from the backend's record ID; other backends' files land at the archive root. Browse with find instead of hard-coding a path.

And the journal copy:

# Summary lines: "PStore dmesg-ramoops-0 moved to ..." journalctl -b -u systemd-pstore.service -o cat # Extract the stored file bodies, if jq is available journalctl -b -u systemd-pstore.service -o json | jq -r 'select(.FILE) | .FILE' 

Two small traps:

  • Files ending in .enc.z are compressed records. systemd-pstore can archive them, but it does not merge them into a readable dmesg.txt; you will need to decompress the file yourself.
  • If Unlink=yes is set, the raw file may already be gone by the time you look. The archive or the journal is the surviving copy.

Test the pipeline without crashing the box

You do not need a panic to verify that ramoops and systemd-pstore are wired correctly. A normal shutdown can produce a record, if you ask for one.

The kernel only dumps the log on shutdown when printk.always_kmsg_dump is enabled. And ramoops filters by max_reason; the default of 2 excludes KMSG_DUMP_SHUTDOWN (4). So both knobs are required:

# /etc/tmpfiles.d/pstore-test.conf w- /sys/module/printk/parameters/always_kmsg_dump - - - - Y 
# 1. Apply the tmpfiles rule (writes Y to the sysfs parameter now) sudo systemd-tmpfiles --create /etc/tmpfiles.d/pstore-test.conf # 2. Load ramoops with max_reason >= 4, for example in # /etc/modprobe.d/ramoops.conf: options ramoops ... max_reason=4 # Then reboot. sudo reboot # 3. After boot, check the archive first: systemd-pstore normally # runs before you log in and may have already unlinked the raw file. sudo find /var/lib/systemd/pstore -type f journalctl -b -u systemd-pstore.service -o cat 

If you want the raw file to remain in /sys/fs/pstore for inspection, set Unlink=no in pstore.conf before rebooting, then turn it back on afterward.

If you get a dmesg-ramoops-* or a shutdown record, the whole path works: backend, frontend, filter, archive. Remove the tmpfiles drop-in and restore max_reason=2 afterward if you only want crash records.

On a disposable VM only, the harder test is:

echo 1 | sudo tee /proc/sys/kernel/sysrq echo c | sudo tee /proc/sysrq-trigger 

That is an immediate kernel crash. Add panic=10 to the kernel command line first, or the VM may simply hang instead of rebooting. Never run this on a machine you care about.

Failure modes worth designing around

  1. The region was never reserved. The driver fails to claim it, or worse, the kernel reuses it. Reserve it in firmware or the device tree.
  2. You sized zones for frontends that are not compiled in. Check CONFIG_PSTORE_CONSOLE, PMSG, and FTRACE before allocating space for them.
  3. The division floors. ECC and odd zone sizes can cost you a whole record. Leave slack.
  4. Default max_reason hides shutdown dumps. If your test produces nothing, check this before blaming the backend.
  5. kdump and pstore can conflict. With kdump armed, pstore may be skipped on panic unless crash_kexec_post_notifiers=1 is set. That setting can also reduce kdump reliability, so decide which evidence path matters more.
  6. A cold power loss loses RAM-backed records. Ramoops survives a warm reset or watchdog reboot; it does not survive the power supply going away. Firmware-backed stores have different guarantees.
  7. Virtual machines are not magic. A host reboot, migration, or memory hotplug can discard the reserved region. Test in the environment you actually run.
  8. It is small. A few hundred kilobytes of text is normal. If you need registers, stacks, and full memory, you need kdump and a vmcore, not pstore.
  9. The files are root-only. Automation that reads them needs privilege; do not widen permissions on /sys/fs/pstore.
  10. systemd may have already moved them. Look in /var/lib/systemd/pstore and the journal, not only at the raw mount.

A short production checklist

  • Enable CONFIG_PSTORE and the backend you can actually support (CONFIG_PSTORE_RAM, CONFIG_PSTORE_BLK, EFI, or ERST).
  • Reserve the region in firmware or device tree; never point ramoops at unreserved RAM.
  • Pick record_size from the size of a useful oops, not from the total region. 64–256 KiB is a common range.
  • Add ECC if hard resets are part of your failure profile, and budget the bytes.
  • Keep max_reason=2 for crash-only capture; raise it only for deliberate shutdown testing.
  • Enable systemd-pstore and keep Storage=external, Unlink=yes unless you have a reason not to.
  • Put the retrieval commands in your runbook, including the archive path and the journal query.
  • Pair pstore with kdump if you need full memory; treat pstore as the last-gasp note, not the investigation.

The kernel's last words are not a replacement for observability. They are what you read when observability has already stopped. Reserving a megabyte and enabling one service is a cheap way to make sure the next 03:12 reboot leaves something behind.

Sources