Enable core dump on Debian

Moki Lv6

Install

1
2
apt-get install -yqq systemd-coredump
ulimit -S -c 0

Configure

1
2
vim /etc/security/limits.conf
vim /etc/sysctl.d/50-coredump.conf

Core pattern

1
2
cat /proc/sys/kernel/core_pattern
sysctl -w kernel.core_pattern=/var/lib/systemd/coredump/core.%u.%e.%p

if kernel.core_pattern starts with then runs program, eg. kernel.core_pattern='/bin/false'

Shortcut

Description

%%

output one ‘%’

%p

pid

%P

global pid (init PID namespace)

%i

tid

%I

global tid (init PID namespace)

%u

uid (in initial user namespace)

%g

gid (in initial user namespace)

%d

Dump mode, matches PR_SET_DUMPABLE and /proc/sys/fs/suid_dumpable

%s

Signal number

%t

UNIX time of dump

%h

hostname

%e

executable filename (may be shortened)

%E

executable path

Configuration

1
2
3
4
5
6
7
8
9
$ echo 'ulimit -S -c 0' >> ~/.bash_profile

$ cat /etc/systemd/coredump.conf.d/custom.conf
[Coredump]
Storage=external
Compress=yes
ProcessSizeMax=0
ExternalSizeMax=16G
JournalSizeMax=16G

To disable

1
2
3
4
$ cat /etc/systemd/coredump.conf.d/custom.conf
[Coredump]
Storage=none
ProcessSizeMax=0

Reload configuration

1
systemctl daemon-reload

Test

1
2
3
sleep 500 &
kill -s 6 [DISPLAYED PID]
ls -la /var/lib/systemd/coredump/

or

1
2
3
ulimit -S -c unlimited sleep 500 &
kill -s 6 [DISPLAYED PID]
ls -la /var/lib/systemd/coredump/