All Products
Search
Document Center

:How do I configure Kdump in a Alibaba Cloud Linux 2 system?

更新時間:Apr 29, 2022

Introduction

The Kdump service is provided by the Alibaba Cloud Linux 2 system. Kernel errors can be captured after this service is enabled to analyze kernel crashes. When Kdump is enabled, it occupies a portion of the operating system memory space. The corresponding user system service kdump.service may affect the system startup speed. In view of this, in the Alibaba Cloud Linux 2 system, the Kdump service is not fully enabled by default, and you need to configure according to actual business needs. This article focuses on the Kdump service on and off options in the Alibaba Cloud Linux 2 system, and explains the corresponding risks and countermeasures.

Background

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

Description of kernel startup option crashkernel

Enabling the Kdump service depends on a memory address space reserved by the kernel. The size of this memory address space is specified by the /proc/cmdline option in the kernel command line parameter crashkernel. We add the crashkernel option to Grub by default, and specify the memory size in separate formats. The overall option is optional, which is described as follows:

  • If you purchase an ECS instance or manually configure an operating system with a memory size less than 2 GiB, memory allocated to the applications will not be reserved for the operating system because the memory available for the applications is insufficient. When the system memory is less than 2 GiB, you cannot use the Kdump function.
  • If you purchase an ECS instance or manually configure an operating system that exceeds 2 GiB but does not exceed 8 GiB, 192 MiB of memory is reserved.
  • If the memory size of your ECS instance or the manually configured operating system exceeds 8 GiB, 256 MiB of memory is reserved.

To verify whether the memory space of the specified size has been reserved on the current operating system, run the following command in the operating system:

cat /sys/kernel/kexec_crash_size

The following command output is returned.

201326592

Note: in the response, the unit of the kexec crash size is bytes.

Enable and disable the Kdump service

The complete Kdump function cannot be implemented only with the crashekernel kernel startup option. Therefore, you need to use Kdump together. To enable or disable the Kdump service, follow these steps:

  1. Refer to the following two methods to check the running status of the Kdump service.
    • Run the following command to view the running status of the service: If the value of Active is inactive, the Kdump service is inactive.
      systemctl status kdump.service
    • Run the following command to check the status of the interface in the kernel: If the return result is 0, the Kdump service is not activated.
      cat /sys/kernel/kexec_crash_loaded
  2. You can enable or disable the Kdump service by referring to the following command.
    • Enable the Kdump service.
      systemctl start kdump.service
    • Disable the Kdump service.
      systemctl stop kdump.service
  3. Follow Step 1 to check whether the Kdump service is running as expected.
  4. You can also run the following command to select whether the Kdump service can automatically start at startup.
    • Start automatically.
      systemctl enable kdump.service
    • Prohibit starting automatically.
      systemctl disable kdump.service

Completely disable the Kdump service and return the memory address space

If your instance does not need to enable the Kdump service and you want to return the memory address space reserved by the system to the operating system to avoid resource waste, you can run the following commands to disable the Kdump service:

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

Run the following command to check whether the memory address space is no longer reserved for Kdump. In other words, 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.

References

Application scope

  • Elastic Compute Service
    Note:
    • Image: images of all versions and later.
    • Kernel: kernel-4.19.24-9.al7 and later versions.