본문 바로가기

카테고리 없음

[리눅스커널] vmcore를 받기 위한 kdump 설정 방법 II (Ubuntu)

Precondition
 
아래 명령어를 입력해 프로그램 목록을 최신으로 업데이트합니다.
 
$ sudo apt-get update
$ sudo apt-get upgrade
 
$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.4.0-59-generic root=UUID=b187438a-b934-498d-86e1-8235e8cb0e3f ro swapaccount=1
 
kdump 설정 방법과 vmcore 추출 하기
 
1. linux-crashdump 설치 
 
아래와 같은 명령어를 실행해 linux-crashdump를 설치합니다.
 
$ sudo apt-get install linux-crashdump
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apport apport-symptoms busybox-initramfs crash grub-common grub-gfxpayload-lists grub-pc grub-pc-bin
...
Configuring kexec-tools
-----------------------
 
If you choose this option, a system reboot will trigger a restart into a kernel loaded by kexec instead of 
going through the full system boot loader process.
 
Should kexec-tools handle reboots (sysvinit only)? [yes/no] 
 
설치 도중에 위와 같은 화면이 뜨면 yes를 입력합니다.
 
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Configuring kdump-tools
-----------------------
 
If you choose this option, the kdump-tools mechanism will be enabled. A reboot is still required in order to 
enable the crashkernel kernel parameter.
 
Should kdump-tools be enabled by default? [yes/no]
 
이번에도 yes를 입력합니다.
 
2. 재부팅합니다.
 
3. /sys/kernel/kexec_crash_loaded 확인
 
/sys/kernel/kexec_crash_loaded 가 1로 되어 있어야 kdump를 사용할 수 있는 상태입니다.
 
$ cat /sys/kernel/kexec_crash_loaded 
1
 
4. /etc/default/kexec 확인
 
/etc/default/kexec 파일에서 USE_GRUB_CONFIG이 true로 설정됐는지 확인합니다.
디폴트로는 false로 설정돼 있습니다.
 
5. kdump-config show 명령어 사용
 
kdump-config show 명령어를 입력해 crashdump 사용 가능한 상태인지 확인합니다.
 
kdump를 설정하고 재부팅하지 않으면 다음과 같은 
결과가 출력됩니다. (current state:    Not ready to kdump)
 
$ kdump-config show
 * no crashkernel= parameter in the kernel cmdline
DUMP_MODE:        kdump
USE_KDUMP:        1
KDUMP_SYSCTL:     kernel.panic_on_oops=1
KDUMP_COREDIR:    /var/crash
crashkernel addr: 
   /var/lib/kdump/vmlinuz
kdump initrd: 
   /var/lib/kdump/initrd.img
current state:    Not ready to kdump
 
kexec command:
  no kexec command recorded
 
'current state:    ready to kdump'으로 출력돼야 kdump를 실행할 수 있습니다.
 
6. crashkernel 설정 변경
 
crashkernel 설정은 kdump-tools.cnf 파일에 정의돼 있습니다.
사이즈를 변경하려면 해당 파일에서 crashkernel로 명시된 부분을 수정합시다.
 
$ cat /etc/default/grub.d/kdump-tools.cfg 
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT crashkernel=512M-:192M"
 
7. Grub Update 적용
 
아래 커맨드를 입력합시다.
 
$ update-grub
 
8. 재부팅 합니다.
 
9. 크래시 유발 커맨드 입력
 
아래 명령어를 입력해 커널 패닉을 유발시킵니다.
 
$ echo c > /proc/sysrq-trigger