All Products
Document Center

How do I configure the Kdump file in a Aliyun Linux 2 system?

Last Updated: Apr 29, 2020


The Aliyun Linux 2 system provides the kdump service. Kernel errors can be captured after this service is enabled to analyze kernel crashes. When Kdump is enabled, it occupies part of the operating system memory space, and the corresponding user-mode system service kdump.service may affect the system startup speed. In view of this, in the Aliyun Linux 2 system, the Kdump service is not fully enabled by default, the user needs to configure according to the actual needs of the business. This topic describes how to enable and disable the Kdump service in a Aliyun Linux 2 system, and provides the corresponding risks and solutions.

Detailed information

Alibaba Cloud reminds you that:

  • If you have any risky operations on an instance or data, pay attention to the disaster tolerance and fault tolerance capabilities of the instance to ensure data security.
  • If you modify the configuration and data of an instance (including but not limited to ECS and RDS), we recommend that you create snapshots or enable RDS log backup.
  • If you have granted permissions on the Alibaba Cloud platform or submitted security information such as the logon account and password, we recommend that you modify the information as soon as possible.

Description of kernel startup option crashkernel

To enable the Kdump service, a memory address space is reserved during kernel operation. The size of the memory address space depends on the kernel command line parameter /proc/cmdline in crashkernel option specifies. By default, we add the crashkernel option and specify the memory size in different sections. The overall options are as follows: crashkernel=0M-2G:0M,2G-8G:192M,8g-:256M.

  • If the memory of your ECS instance or operating system is less than 2GiB, memory will no longer be reserved for the operating system. Therefore, if the system memory is less than 2GiB, you cannot use Kdump.
  • If you purchase an ECS instance or manually set an operating system with a memory size greater than 2GiB but less than 8GiB, the system reserves a memory size of 192MiB for the instance.
  • If the memory of your ECS instance or your manually configured operating system exceeds 8GiB, the system reserves a excess memory size of 256MiB.

To check whether the memory is reserved on the operating system, run the following command in the operating system:

cat /sys/kernel/kexec_crash_size

A similar output is displayed.


Note: in the returned results, kexec crash size unit: bytes.

Enable and disable system services through Kdump

Only crashekernel the kernel startup option cannot implement the complete Kdump function. You must use the Kdump service together with this function. Follow these steps to enable or disable the Kdump service.

  1. To check the running status of the Kdump service, follow these two methods:
    • Run the following command to check the service status: If the value of Active in the response is inactive, the Kdump service is not activated.
      systemctl status kdump.service
    • Run the following command to check the kernel interface status: "If" 0 "is returned, the Kdump service is in the inactive state."
      cat /sys/kernel/kexec_crash_loaded
  2. You can run the following commands to enable or disable the Kdump service:
    • Enable the Kdump service.
      systemctl start kdump.service
    • Disable the Kdump service.
      systemctl stop kdump.service
  3. Refer to Step 1 to check whether the Kdump service is running as expected.
  4. You can run the following command to enable or disable the Kdump service.
    • Starts automatically.
      systemctl enable kdump.service
    • It is forbidden to start automatically when the device starts up.
      systemctl disable kdump.service

Completely disable the Kdump service and return the memory address space

If the Kdump service is not required for your instance, and you want to return the memory address space reserved by the system to the operating system to avoid resource waste, you can disable the Kdump service by running the following command.

sh -c 'echo 0 > /sys/kernel/kexec_crash_size'
systemctl disable kdump.service
systemctl stop kdump.service

Run the following command to verify that the memory address space is no longer reserved for Kdump. The returned value is '0'.

cat /sys/kernel/kexec_crash_size

Note: after the memory address space reserved by the Kdump service is returned to the operating system, the operating system must be restarted to enable the Kdump service again.

Related Documents

Applicable to

  • Elastic Compute Service