Linux #20 : RedHat Linux Kernel Crash Analysis

지난 시간에는 NetDump를 통한 Crash Dump에 대해서 적었었죠.
(그 이후 몇 달만에 이 글을 쓰는지 모르겠네요. 정리는 한 참 전에 해 놓고.. 나름 바쁘다는 핑계로 = =;)
Dump를 뜨는 것도 중요하죠. Console화면을 놓치는 경우 Linux에서 발생한 Kernel Panic과 같은 Error를 Dump File이 없이 확인 하는 게 어렵기 때문에.
그럼, 그걸 분석하는 방법을 배워야 겠죠.

그래서 RedHat Crash Utility라는게 존재 합니다. 이 Tool을 사용하기 위해서는 3개지의 전제 조건이 필요합니다.

  • Kernel Object File : A vmlinux Kernel Object file이 있어야하고, 일반적으로는 /boot, /lib/modules에서 존재합니다.
  • Kernel Crash Dump : Diskdump, Netdump, Kdump 등에 의해서 Dump된 Filename이 vmcore 혹은 vmcore.incomplete가 있어야하며 일반적으로 /var/crash에 저장됩니다.
  • Linux Kernel Version : Red Hat Linux 6.0 이하가 아니면 됩니다.

** 여기서 사용한 Version은 RHEL 4 U5 x86_64입니다.

Install Crash Utility의 설치
설치는 간단하게 RPM Package로 가능합니다. 설치된 crash file의 경로는 /usr/bin/crash.

$ rpm -ivh crash-4.0-3.9.x86_64.rpm
warning: crash-4.0-3.9.x86_64.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing... ########################################### [100%]
1:crash ########################################### [100%]

또한, Kernel을 Debug하기 위한 Kernel-debuginfo RPM Package가 필요하다.

# rpm -ivh kernel-debuginfo-2.6.9-55.EL.x86_64.rpm
Preparing... ########################################### [100%]
1:kernel-debuginfo ########################################### [100%]
# ls -l /usr/lib/debug/lib/modules/
total 16
drwxr-xr-x 3 root root 4096 Apr 25 17:55 2.6.9-55.EL
drwxr-xr-x 3 root root 4096 Apr 25 17:55 2.6.9-55.ELlargesmp
drwxr-xr-x 3 root root 4096 Apr 25 17:56 2.6.9-55.ELsmp
drwxr-xr-x 3 root root 4096 Apr 25 17:56 2.6.9-55.ELxenU
# ls -l /usr/lib/debug/lib/modules/2.6.9-55.EL
total 38320
drwxr-xr-x 9 root root 4096 Mar 21 15:24 kernel
-rwxr-xr-x 1 root root 39190296 Apr 20 2007 vmlinux

위에서 언급 한 것 처럼 System Crash(Kernal Panic)에 의해 저장되는 file은 vmcore이고, 해당 file은 /var/crash에 저장된다.
Dump를 통해서 저장 된 vmcore file을 확인 해 보자.

# strings vmcore | fgrep -m1 'Linux '
Linux version 2.6.9-55.ELsmp ([email protected]) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)) #1 SMP Fri Apr 20 16:36:54 EDT 2007

이제 모든 준비가 완료 되었으니, crash를 실행 해 봅시다. 아래와 같이 실행합니다.

# crash [Module vmlinux의 위치] [vmcore file의 위치]

# crash /usr/lib/debug/lib/modules/2.6.9-55.ELsmp/vmlinux /var/crash/[IP Address]-2011-03-16-22\:28/vmcore

crash 4.0-3.9
Copyright (C) 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
Copyright (C) 2004, 2005, 2006 IBM Corporation
Copyright (C) 1999-2006 Hewlett-Packard Co
Copyright (C) 2005 Fujitsu Limited
Copyright (C) 2005 NEC Corporation
Copyright (C) 1999, 2002 Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions. Enter "help copying" to see the conditions.
This program has absolutely no warranty. Enter "help warranty" for details.

GNU gdb 6.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...

KERNEL: /usr/lib/debug/lib/modules/2.6.9-55.ELsmp/vmlinux
DUMPFILE: /var/crash/[IP Address]-2011-03-16-22:28/vmcore
CPUS: 8
DATE: Sat Mar 19 13:24:07 2011
UPTIME: 9 days, 17:24:48
LOAD AVERAGE: 0.25, 0.28, 0.22
TASKS: 190
NODENAME: [HostName]
RELEASE: 2.6.9-55.ELsmp
VERSION: #1 SMP Fri Apr 20 16:36:54 EDT 2007
MACHINE: x86_64 (2666 Mhz)
MEMORY: 8.7 GB
PANIC: ""
PID: 0
COMMAND: "swapper"
TASK: 10037e627f0 (1 of 8) [THREAD_INFO: 100069a6000]
CPU: 6
STATE: TASK_RUNNING (PANIC)

crash>

얼마전에 절 괴롭혔던 HP DL360G5 장비의 Memory 관련 Error 입니다. Physical Memory Check를 해도 Error가 검출되지 않아
결국 Server와 Memory를 교체하고 그 뒤로 동일한 Error는 발생하지 않았습니다.

Crash의 명령어를 통해 좀 더 다양하게 확인 가능합니다.. 명령어는 아래와 같이 help 로 확인 할 수 있습니다.

crash> help

* files mod runq union
alias foreach mount search vm
ascii fuser net set vtop
bt gdb p sig waitq
btop help ps struct whatis
dev irq pte swap wr
dis kmem ptob sym q
eval list ptov sys
exit log rd task
extend mach repeat timer

crash version: 4.0-3.9 gdb version: 6.1
For help on any command above, enter "help ".
For help on input options, enter "help input".
For help on output options, enter "help output".

1 thought on “Linux #20 : RedHat Linux Kernel Crash Analysis

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.