How to enable/disable core dumps on Linux

Prev Next

Occasionally there can be issues within a VM that the swxtch.io logs do not capture.  In this case core dumps will assist in trouble shooting the issue.  Caution:  Core dumps can take space and should only be enabled when issues occur.

To check to see if core dumps are enabled for unlimited, 0 means disabled.

ulimit -c

Example:

To enable core dumps to unlimited for the current session:

ulimit -c 102400 

This will set it to 100MB Limit Warning: -c unlimited  can fill up the drive, be sure to disable once the dumps are created and saved off.  

Result:

To disable:

ulimit -c 0

To enable permanently

sudo nano /etc/security/limits.conf

Add lines for non-specific user:

*               soft    core            fsize 51200
*               hard    core            fsize 51200

The * applies to all users. You can also specify individual users or groups instead.

fsize - maximum file size (KB).  In place of fsize you can also set to Unlimited, but this could fill up your drive.

For specific user:

username        soft    core            fsize 51200
username        hard    core            fsize 51200

fsize - maximum file size (KB).  In place of fsize you can also set to Unlimited, but this could fill up your drive.

To disable, remove lines.

Reboot for it to take place.

To find a core dump:

Check the current working directory.  If no specific configuration is in place, search the directory where the crashing program was executed.

Check /var/spool/abrt:

On RHEL systems, check this directory.

Check /var/lib/apport/coredump:

On Ubuntu/Debian, check this location.  Examine kernel.core_pattern to see if a custom path has been set.

cat /proc/sys/kernel/core_pattern 

Example: