Enable Core Dump systemd

From Proxmox VE
Revision as of 11:26, 16 August 2022 by A.lauterer (talk | contribs) (→‎Test it: use kill -11 sigsegv)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

This is a HowToDO to enable Core Dump with systemd on PVE 4.0 (Debian Jessie).

Requirements

To activate you have to create

/etc/security/limits.d/core.conf
/etc/sysctl.d/core.conf
/var/lib/coredumps

Allow Dump from CLI

To allow root to core dump from cli.

Edit: /etc/security/limits.d/core.conf

root       hard        core        unlimited
root       soft        core        unlimited

Allow Dump from Daemons

To allow all daemons witch are started by systemd to core dump.

Edit: /etc/systemd/system.conf add following

DefaultLimitCORE=infinity

Edit: /etc/sysctl.d/core.conf add following

kernel.core_pattern = /var/lib/coredumps/core-%e-sig%s-user%u-group%g-pid%p-time%t
kernel.core_uses_pid = 1
fs.suid_dumpable = 2

Reboot Server

To activate this settings reboot the server.

Note: normally it should be enough to call

systemctl daemon-reexec

but it didn't work for me

Test it

To test if everything is working fine do this few steps to verify.

root@pve:~# systemctl status pveproxy.service 
● pveproxy.service - PVE API Proxy Server
  Loaded: loaded (/lib/systemd/system/pveproxy.service; enabled)
  Active: active (running) since Mon 2015-05-11 08:54:50 CEST; 6h ago
 Process: 1280 ExecStart=/usr/bin/pveproxy start (code=exited, status=0/SUCCESS)
Main PID: 1281 (pveproxy)
  CGroup: /system.slice/pveproxy.service
          ├─1281 pveproxy
          ├─1282 pveproxy worker
          ├─1283 pveproxy worker
          └─1284 pveproxy worker
May 11 08:54:50 sasha pveproxy[1280]: Can't stat /usr/share/pve-manager/man...ry
May 11 08:54:50 sasha pveproxy[1280]: at /usr/bin/pveproxy line 74.
May 11 08:54:50 sasha pveproxy[1280]: Can't stat /usr/share/pve-manager/man...ry
                                      at /usr/bin/pveproxy line 74.
May 11 08:54:50 sasha pveproxy[1281]: starting server
May 11 08:54:50 sasha pveproxy[1281]: starting 3 worker(s)
May 11 08:54:50 sasha pveproxy[1281]: worker 1282 started
May 11 08:54:50 sasha pveproxy[1281]: worker 1283 started
May 11 08:54:50 sasha pveproxy[1281]: worker 1284 started
Hint: Some lines were ellipsized, use -l to show in full.
root@pve:kill -11 1281

root@pve:~# ls -hal /var/lib/coredumps/ 
total 3.1M
drwxrwx-wx  2 root root 4.0K May 11 08:55 .
drwxr-xr-x 50 root root 4.0K May 11 08:16 ..
-rw-------  1 root www-data  88M May 11 15:43 core-pveproxy-sig11-user33-group33-pid13696-time1431351789
root@pve:~# systemctl start pveproxy.service