blob: 08bafa8c1caa91058a2d1c1eb91128e70668781d [file] [log] [blame]
David Wilderdc851a02006-06-25 05:47:55 -07001================================================================
2Documentation for Kdump - The kexec-based Crash Dumping Solution
Vivek Goyalb089f4a2005-06-25 14:58:15 -07003================================================================
4
David Wilderdc851a02006-06-25 05:47:55 -07005This document includes overview, setup and installation, and analysis
6information.
Vivek Goyalb089f4a2005-06-25 14:58:15 -07007
David Wilderdc851a02006-06-25 05:47:55 -07008Overview
9========
Vivek Goyalb089f4a2005-06-25 14:58:15 -070010
David Wilderdc851a02006-06-25 05:47:55 -070011Kdump uses kexec to quickly boot to a dump-capture kernel whenever a
12dump of the system kernel's memory needs to be taken (for example, when
13the system panics). The system kernel's memory image is preserved across
14the reboot and is accessible to the dump-capture kernel.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070015
David Wilderdc851a02006-06-25 05:47:55 -070016You can use common Linux commands, such as cp and scp, to copy the
17memory image to a dump file on the local disk, or across the network to
18a remote system.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070019
David Wilderdc851a02006-06-25 05:47:55 -070020Kdump and kexec are currently supported on the x86, x86_64, and ppc64
21architectures.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070022
David Wilderdc851a02006-06-25 05:47:55 -070023When the system kernel boots, it reserves a small section of memory for
24the dump-capture kernel. This ensures that ongoing Direct Memory Access
25(DMA) from the system kernel does not corrupt the dump-capture kernel.
26The kexec -p command loads the dump-capture kernel into this reserved
27memory.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070028
David Wilderdc851a02006-06-25 05:47:55 -070029On x86 machines, the first 640 KB of physical memory is needed to boot,
30regardless of where the kernel loads. Therefore, kexec backs up this
31region just before rebooting into the dump-capture kernel.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070032
David Wilderdc851a02006-06-25 05:47:55 -070033All of the necessary information about the system kernel's core image is
34encoded in the ELF format, and stored in a reserved area of memory
35before a crash. The physical address of the start of the ELF header is
36passed to the dump-capture kernel through the elfcorehdr= boot
37parameter.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070038
David Wilderdc851a02006-06-25 05:47:55 -070039With the dump-capture kernel, you can access the memory image, or "old
40memory," in two ways:
Vivek Goyalb089f4a2005-06-25 14:58:15 -070041
David Wilderdc851a02006-06-25 05:47:55 -070042- Through a /dev/oldmem device interface. A capture utility can read the
43 device file and write out the memory in raw format. This is a raw dump
44 of memory. Analysis and capture tools must be intelligent enough to
45 determine where to look for the right information.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070046
David Wilderdc851a02006-06-25 05:47:55 -070047- Through /proc/vmcore. This exports the dump as an ELF-format file that
48 you can write out using file copy commands such as cp or scp. Further,
49 you can use analysis tools such as the GNU Debugger (GDB) and the Crash
50 tool to debug the dump file. This method ensures that the dump pages are
51 correctly ordered.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070052
Vivek Goyalb089f4a2005-06-25 14:58:15 -070053
David Wilderdc851a02006-06-25 05:47:55 -070054Setup and Installation
55======================
Vivek Goyalb089f4a2005-06-25 14:58:15 -070056
David Wilderdc851a02006-06-25 05:47:55 -070057Install kexec-tools and the Kdump patch
58---------------------------------------
Vivek Goyalb089f4a2005-06-25 14:58:15 -070059
David Wilderdc851a02006-06-25 05:47:55 -0700601) Login as the root user.
Vivek Goyalb089f4a2005-06-25 14:58:15 -070061
David Wilderdc851a02006-06-25 05:47:55 -0700622) Download the kexec-tools user-space package from the following URL:
Vivek Goyalb089f4a2005-06-25 14:58:15 -070063
David Wilderdc851a02006-06-25 05:47:55 -070064 http://www.xmission.com/~ebiederm/files/kexec/kexec-tools-1.101.tar.gz
Vivek Goyalb089f4a2005-06-25 14:58:15 -070065
David Wilderdc851a02006-06-25 05:47:55 -0700663) Unpack the tarball with the tar command, as follows:
67
68 tar xvpzf kexec-tools-1.101.tar.gz
69
704) Download the latest consolidated Kdump patch from the following URL:
71
72 http://lse.sourceforge.net/kdump/
73
74 (This location is being used until all the user-space Kdump patches
75 are integrated with the kexec-tools package.)
76
775) Change to the kexec-tools-1.101 directory, as follows:
78
79 cd kexec-tools-1.101
80
816) Apply the consolidated patch to the kexec-tools-1.101 source tree
82 with the patch command, as follows. (Modify the path to the downloaded
83 patch as necessary.)
84
85 patch -p1 < /path-to-kdump-patch/kexec-tools-1.101-kdump.patch
86
877) Configure the package, as follows:
88
89 ./configure
90
918) Compile the package, as follows:
92
93 make
94
959) Install the package, as follows:
96
97 make install
98
99
100Download and build the system and dump-capture kernels
101------------------------------------------------------
102
103Download the mainline (vanilla) kernel source code (2.6.13-rc1 or newer)
104from http://www.kernel.org. Two kernels must be built: a system kernel
105and a dump-capture kernel. Use the following steps to configure these
106kernels with the necessary kexec and Kdump features:
107
108System kernel
109-------------
110
1111) Enable "kexec system call" in "Processor type and features."
112
113 CONFIG_KEXEC=y
114
1152) Enable "sysfs file system support" in "Filesystem" -> "Pseudo
116 filesystems." This is usually enabled by default.
117
118 CONFIG_SYSFS=y
119
120 Note that "sysfs file system support" might not appear in the "Pseudo
121 filesystems" menu if "Configure standard kernel features (for small
122 systems)" is not enabled in "General Setup." In this case, check the
123 .config file itself to ensure that sysfs is turned on, as follows:
124
125 grep 'CONFIG_SYSFS' .config
126
1273) Enable "Compile the kernel with debug info" in "Kernel hacking."
128
129 CONFIG_DEBUG_INFO=Y
130
131 This causes the kernel to be built with debug symbols. The dump
132 analysis tools require a vmlinux with debug symbols in order to read
133 and analyze a dump file.
134
1354) Make and install the kernel and its modules. Update the boot loader
136 (such as grub, yaboot, or lilo) configuration files as necessary.
137
1385) Boot the system kernel with the boot parameter "crashkernel=Y@X",
139 where Y specifies how much memory to reserve for the dump-capture kernel
140 and X specifies the beginning of this reserved memory. For example,
141 "crashkernel=64M@16M" tells the system kernel to reserve 64 MB of memory
142 starting at physical address 0x01000000 for the dump-capture kernel.
143
144 On x86 and x86_64, use "crashkernel=64M@16M".
145
146 On ppc64, use "crashkernel=128M@32M".
147
148
149The dump-capture kernel
150-----------------------
151
1521) Under "General setup," append "-kdump" to the current string in
153 "Local version."
154
1552) On x86, enable high memory support under "Processor type and
156 features":
157
158 CONFIG_HIGHMEM64G=y
159 or
160 CONFIG_HIGHMEM4G
161
1623) On x86 and x86_64, disable symmetric multi-processing support
163 under "Processor type and features":
164
165 CONFIG_SMP=n
166 (If CONFIG_SMP=y, then specify maxcpus=1 on the kernel command line
167 when loading the dump-capture kernel, see section "Load the Dump-capture
168 Kernel".)
169
1704) On ppc64, disable NUMA support and enable EMBEDDED support:
171
172 CONFIG_NUMA=n
173 CONFIG_EMBEDDED=y
174 CONFIG_EEH=N for the dump-capture kernel
175
1765) Enable "kernel crash dumps" support under "Processor type and
177 features":
178
179 CONFIG_CRASH_DUMP=y
180
1816) Use a suitable value for "Physical address where the kernel is
182 loaded" (under "Processor type and features"). This only appears when
183 "kernel crash dumps" is enabled. By default this value is 0x1000000
184 (16MB). It should be the same as X in the "crashkernel=Y@X" boot
185 parameter discussed above.
186
187 On x86 and x86_64, use "CONFIG_PHYSICAL_START=0x1000000".
188
189 On ppc64 the value is automatically set at 32MB when
190 CONFIG_CRASH_DUMP is set.
191
1926) Optionally enable "/proc/vmcore support" under "Filesystems" ->
193 "Pseudo filesystems".
194
195 CONFIG_PROC_VMCORE=y
196 (CONFIG_PROC_VMCORE is set by default when CONFIG_CRASH_DUMP is selected.)
197
1987) Make and install the kernel and its modules. DO NOT add this kernel
199 to the boot loader configuration files.
200
201
202Load the Dump-capture Kernel
203============================
204
205After booting to the system kernel, load the dump-capture kernel using
206the following command:
207
208 kexec -p <dump-capture-kernel> \
209 --initrd=<initrd-for-dump-capture-kernel> --args-linux \
210 --append="root=<root-dev> init 1 irqpoll"
211
212
213Notes on loading the dump-capture kernel:
214
215* <dump-capture-kernel> must be a vmlinux image (that is, an
216 uncompressed ELF image). bzImage does not work at this time.
217
218* By default, the ELF headers are stored in ELF64 format to support
219 systems with more than 4GB memory. The --elf32-core-headers option can
220 be used to force the generation of ELF32 headers. This is necessary
221 because GDB currently cannot open vmcore files with ELF64 headers on
222 32-bit systems. ELF32 headers can be used on non-PAE systems (that is,
223 less than 4GB of memory).
224
225* The "irqpoll" boot parameter reduces driver initialization failures
226 due to shared interrupts in the dump-capture kernel.
227
228* You must specify <root-dev> in the format corresponding to the root
229 device name in the output of mount command.
230
231* "init 1" boots the dump-capture kernel into single-user mode without
232 networking. If you want networking, use "init 3."
233
234
235Kernel Panic
236============
237
238After successfully loading the dump-capture kernel as previously
239described, the system will reboot into the dump-capture kernel if a
240system crash is triggered. Trigger points are located in panic(),
241die(), die_nmi() and in the sysrq handler (ALT-SysRq-c).
242
243The following conditions will execute a crash trigger point:
244
245If a hard lockup is detected and "NMI watchdog" is configured, the system
246will boot into the dump-capture kernel ( die_nmi() ).
247
248If die() is called, and it happens to be a thread with pid 0 or 1, or die()
249is called inside interrupt context or die() is called and panic_on_oops is set,
250the system will boot into the dump-capture kernel.
251
252On powererpc systems when a soft-reset is generated, die() is called by all cpus and the system system will boot into the dump-capture kernel.
253
254For testing purposes, you can trigger a crash by using "ALT-SysRq-c",
255"echo c > /proc/sysrq-trigger or write a module to force the panic.
256
257Write Out the Dump File
258=======================
259
260After the dump-capture kernel is booted, write out the dump file with
261the following command:
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700262
263 cp /proc/vmcore <dump-file>
264
David Wilderdc851a02006-06-25 05:47:55 -0700265You can also access dumped memory as a /dev/oldmem device for a linear
266and raw view. To create the device, use the following command:
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700267
David Wilderdc851a02006-06-25 05:47:55 -0700268 mknod /dev/oldmem c 1 12
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700269
David Wilderdc851a02006-06-25 05:47:55 -0700270Use the dd command with suitable options for count, bs, and skip to
271access specific portions of the dump.
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700272
David Wilderdc851a02006-06-25 05:47:55 -0700273To see the entire memory, use the following command:
274
275 dd if=/dev/oldmem of=oldmem.001
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700276
Maneesh Sonia7e670d2006-01-09 20:51:53 -0800277
David Wilderdc851a02006-06-25 05:47:55 -0700278Analysis
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700279========
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700280
David Wilderdc851a02006-06-25 05:47:55 -0700281Before analyzing the dump image, you should reboot into a stable kernel.
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700282
David Wilderdc851a02006-06-25 05:47:55 -0700283You can do limited analysis using GDB on the dump file copied out of
284/proc/vmcore. Use the debug vmlinux built with -g and run the following
285command:
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700286
David Wilderdc851a02006-06-25 05:47:55 -0700287 gdb vmlinux <dump-file>
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700288
David Wilderdc851a02006-06-25 05:47:55 -0700289Stack trace for the task on processor 0, register display, and memory
290display work fine.
291
292Note: GDB cannot analyze core files generated in ELF64 format for x86.
293On systems with a maximum of 4GB of memory, you can generate
294ELF32-format headers using the --elf32-core-headers kernel option on the
295dump kernel.
296
297You can also use the Crash utility to analyze dump files in Kdump
298format. Crash is available on Dave Anderson's site at the following URL:
299
300 http://people.redhat.com/~anderson/
Maneesh Sonia7e670d2006-01-09 20:51:53 -0800301
302
David Wilderdc851a02006-06-25 05:47:55 -0700303To Do
304=====
305
3061) Provide a kernel pages filtering mechanism, so core file size is not
307 extreme on systems with huge memory banks.
308
3092) Relocatable kernel can help in maintaining multiple kernels for
310 crash_dump, and the same kernel as the system kernel can be used to
311 capture the dump.
Maneesh Sonia7e670d2006-01-09 20:51:53 -0800312
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700313
David Wilderdc851a02006-06-25 05:47:55 -0700314Contact
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700315=======
David Wilderdc851a02006-06-25 05:47:55 -0700316
Vivek Goyalb089f4a2005-06-25 14:58:15 -0700317Vivek Goyal (vgoyal@in.ibm.com)
Vivek Goyald58831e2005-06-25 14:58:17 -0700318Maneesh Soni (maneesh@in.ibm.com)
David Wilderdc851a02006-06-25 05:47:55 -0700319
320
321Trademark
322=========
323
324Linux is a trademark of Linus Torvalds in the United States, other
325countries, or both.