Configure core dumps

A core dump is optionally generated by the Linux kernel when it detects that an application or service process has crashed. It contains the running state of the system when the crash occurs, and allows developers to investigate and diagnose the cause of a crash.

By default, the restricted environment used by snap packages and Ubuntu Core prohibits the meaningful generation of a core dump of a snap application or service.

When running on a boot-base of core24+ with snapd 2.65 onwards (both currently in beta), the systemd-coredump service run by the kernel to generate a core dump is now included in the base, and can be invoked from within the snap environment with a system setting.

Enable core dump generation

To enable core dump generation, set the system.coredump.enable system option to true:

sudo snap set system system.coredump.enable=true

When a process crashes, it will now generate a core dump that can be investigated using, for example, the standard coredumpctl utility.

Limit core dump size

The system.coredump.maxuse system option can be used to limit the storage space used for core dumps.

The accepted format for this setting is one of: <bytes> | <bytes/2^20>M | <bytes/2^30>G (similar to other system settings involving sizes).

If unset, space will default to 10% of the total disk size.

If set to 0, no limit will be applied. This behaviour matches the MaxUse coredump configuration option.

For example, the following will limit storage used for core dumps to 100M:

sudo snap set system system.coredump.maxuse=100M

List and view core dumps

Run sudo coredumpctl see the list of core dumps available in the system:

$ sudo coredumpctl
TIME PID UID GID SIG COREFILE EXE SIZE
Fri 2024-09-27 19:51:34 UTC 1742 1000 1000 SIGABRT present /usr/bin/sleep 20.6K

Additional information about the core dump can be shown with sudo coredumpctl info

A tool such as gdb is used to step through the contents of a core dump. Due to the privileged system requirements of such tools, they may not be available on Ubuntu Core. In such cases, a core dump can be exported to a file and copied to a classic Ubuntu system:

sudo coredumpctl dump --output=core

Disable core dump generation

To disable core dump generation, set the system.coredump.enable system option to false:

sudo snap set system system.coredump.enable=true

When core dumps are disabled, systemd-coredump continues to store crash details without the core dump. A value of none will then be shown when core dumps are listed.

For instance:

$ sudo coredumpctl
TIME PID UID GID SIG COREFILE EXE SIZE
Fri 2024-09-27 20:26:40 UTC 1852 1000 1000 SIGABRT none /usr/bin/sleep -