kdump.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. ================================================================
  2. Documentation for Kdump - The kexec-based Crash Dumping Solution
  3. ================================================================
  4. This document includes overview, setup and installation, and analysis
  5. information.
  6. Overview
  7. ========
  8. Kdump uses kexec to quickly boot to a dump-capture kernel whenever a
  9. dump of the system kernel's memory needs to be taken (for example, when
  10. the system panics). The system kernel's memory image is preserved across
  11. the reboot and is accessible to the dump-capture kernel.
  12. You can use common Linux commands, such as cp and scp, to copy the
  13. memory image to a dump file on the local disk, or across the network to
  14. a remote system.
  15. Kdump and kexec are currently supported on the x86, x86_64, and ppc64
  16. architectures.
  17. When the system kernel boots, it reserves a small section of memory for
  18. the dump-capture kernel. This ensures that ongoing Direct Memory Access
  19. (DMA) from the system kernel does not corrupt the dump-capture kernel.
  20. The kexec -p command loads the dump-capture kernel into this reserved
  21. memory.
  22. On x86 machines, the first 640 KB of physical memory is needed to boot,
  23. regardless of where the kernel loads. Therefore, kexec backs up this
  24. region just before rebooting into the dump-capture kernel.
  25. All of the necessary information about the system kernel's core image is
  26. encoded in the ELF format, and stored in a reserved area of memory
  27. before a crash. The physical address of the start of the ELF header is
  28. passed to the dump-capture kernel through the elfcorehdr= boot
  29. parameter.
  30. With the dump-capture kernel, you can access the memory image, or "old
  31. memory," in two ways:
  32. - Through a /dev/oldmem device interface. A capture utility can read the
  33. device file and write out the memory in raw format. This is a raw dump
  34. of memory. Analysis and capture tools must be intelligent enough to
  35. determine where to look for the right information.
  36. - Through /proc/vmcore. This exports the dump as an ELF-format file that
  37. you can write out using file copy commands such as cp or scp. Further,
  38. you can use analysis tools such as the GNU Debugger (GDB) and the Crash
  39. tool to debug the dump file. This method ensures that the dump pages are
  40. correctly ordered.
  41. Setup and Installation
  42. ======================
  43. Install kexec-tools and the Kdump patch
  44. ---------------------------------------
  45. 1) Login as the root user.
  46. 2) Download the kexec-tools user-space package from the following URL:
  47. http://www.xmission.com/~ebiederm/files/kexec/kexec-tools-1.101.tar.gz
  48. 3) Unpack the tarball with the tar command, as follows:
  49. tar xvpzf kexec-tools-1.101.tar.gz
  50. 4) Download the latest consolidated Kdump patch from the following URL:
  51. http://lse.sourceforge.net/kdump/
  52. (This location is being used until all the user-space Kdump patches
  53. are integrated with the kexec-tools package.)
  54. 5) Change to the kexec-tools-1.101 directory, as follows:
  55. cd kexec-tools-1.101
  56. 6) Apply the consolidated patch to the kexec-tools-1.101 source tree
  57. with the patch command, as follows. (Modify the path to the downloaded
  58. patch as necessary.)
  59. patch -p1 < /path-to-kdump-patch/kexec-tools-1.101-kdump.patch
  60. 7) Configure the package, as follows:
  61. ./configure
  62. 8) Compile the package, as follows:
  63. make
  64. 9) Install the package, as follows:
  65. make install
  66. Download and build the system and dump-capture kernels
  67. ------------------------------------------------------
  68. Download the mainline (vanilla) kernel source code (2.6.13-rc1 or newer)
  69. from http://www.kernel.org. Two kernels must be built: a system kernel
  70. and a dump-capture kernel. Use the following steps to configure these
  71. kernels with the necessary kexec and Kdump features:
  72. System kernel
  73. -------------
  74. 1) Enable "kexec system call" in "Processor type and features."
  75. CONFIG_KEXEC=y
  76. 2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo
  77. filesystems." This is usually enabled by default.
  78. CONFIG_SYSFS=y
  79. Note that "sysfs file system support" might not appear in the "Pseudo
  80. filesystems" menu if "Configure standard kernel features (for small
  81. systems)" is not enabled in "General Setup." In this case, check the
  82. .config file itself to ensure that sysfs is turned on, as follows:
  83. grep 'CONFIG_SYSFS' .config
  84. 3) Enable "Compile the kernel with debug info" in "Kernel hacking."
  85. CONFIG_DEBUG_INFO=Y
  86. This causes the kernel to be built with debug symbols. The dump
  87. analysis tools require a vmlinux with debug symbols in order to read
  88. and analyze a dump file.
  89. 4) Make and install the kernel and its modules. Update the boot loader
  90. (such as grub, yaboot, or lilo) configuration files as necessary.
  91. 5) Boot the system kernel with the boot parameter "crashkernel=Y@X",
  92. where Y specifies how much memory to reserve for the dump-capture kernel
  93. and X specifies the beginning of this reserved memory. For example,
  94. "crashkernel=64M@16M" tells the system kernel to reserve 64 MB of memory
  95. starting at physical address 0x01000000 for the dump-capture kernel.
  96. On x86 and x86_64, use "crashkernel=64M@16M".
  97. On ppc64, use "crashkernel=128M@32M".
  98. The dump-capture kernel
  99. -----------------------
  100. 1) Under "General setup," append "-kdump" to the current string in
  101. "Local version."
  102. 2) On x86, enable high memory support under "Processor type and
  103. features":
  104. CONFIG_HIGHMEM64G=y
  105. or
  106. CONFIG_HIGHMEM4G
  107. 3) On x86 and x86_64, disable symmetric multi-processing support
  108. under "Processor type and features":
  109. CONFIG_SMP=n
  110. (If CONFIG_SMP=y, then specify maxcpus=1 on the kernel command line
  111. when loading the dump-capture kernel, see section "Load the Dump-capture
  112. Kernel".)
  113. 4) On ppc64, disable NUMA support and enable EMBEDDED support:
  114. CONFIG_NUMA=n
  115. CONFIG_EMBEDDED=y
  116. CONFIG_EEH=N for the dump-capture kernel
  117. 5) Enable "kernel crash dumps" support under "Processor type and
  118. features":
  119. CONFIG_CRASH_DUMP=y
  120. 6) Use a suitable value for "Physical address where the kernel is
  121. loaded" (under "Processor type and features"). This only appears when
  122. "kernel crash dumps" is enabled. By default this value is 0x1000000
  123. (16MB). It should be the same as X in the "crashkernel=Y@X" boot
  124. parameter discussed above.
  125. On x86 and x86_64, use "CONFIG_PHYSICAL_START=0x1000000".
  126. On ppc64 the value is automatically set at 32MB when
  127. CONFIG_CRASH_DUMP is set.
  128. 6) Optionally enable "/proc/vmcore support" under "Filesystems" ->
  129. "Pseudo filesystems".
  130. CONFIG_PROC_VMCORE=y
  131. (CONFIG_PROC_VMCORE is set by default when CONFIG_CRASH_DUMP is selected.)
  132. 7) Make and install the kernel and its modules. DO NOT add this kernel
  133. to the boot loader configuration files.
  134. Load the Dump-capture Kernel
  135. ============================
  136. After booting to the system kernel, load the dump-capture kernel using
  137. the following command:
  138. kexec -p <dump-capture-kernel> \
  139. --initrd=<initrd-for-dump-capture-kernel> --args-linux \
  140. --append="root=<root-dev> init 1 irqpoll"
  141. Notes on loading the dump-capture kernel:
  142. * <dump-capture-kernel> must be a vmlinux image (that is, an
  143. uncompressed ELF image). bzImage does not work at this time.
  144. * By default, the ELF headers are stored in ELF64 format to support
  145. systems with more than 4GB memory. The --elf32-core-headers option can
  146. be used to force the generation of ELF32 headers. This is necessary
  147. because GDB currently cannot open vmcore files with ELF64 headers on
  148. 32-bit systems. ELF32 headers can be used on non-PAE systems (that is,
  149. less than 4GB of memory).
  150. * The "irqpoll" boot parameter reduces driver initialization failures
  151. due to shared interrupts in the dump-capture kernel.
  152. * You must specify <root-dev> in the format corresponding to the root
  153. device name in the output of mount command.
  154. * "init 1" boots the dump-capture kernel into single-user mode without
  155. networking. If you want networking, use "init 3."
  156. Kernel Panic
  157. ============
  158. After successfully loading the dump-capture kernel as previously
  159. described, the system will reboot into the dump-capture kernel if a
  160. system crash is triggered. Trigger points are located in panic(),
  161. die(), die_nmi() and in the sysrq handler (ALT-SysRq-c).
  162. The following conditions will execute a crash trigger point:
  163. If a hard lockup is detected and "NMI watchdog" is configured, the system
  164. will boot into the dump-capture kernel ( die_nmi() ).
  165. If die() is called, and it happens to be a thread with pid 0 or 1, or die()
  166. is called inside interrupt context or die() is called and panic_on_oops is set,
  167. the system will boot into the dump-capture kernel.
  168. On powererpc systems when a soft-reset is generated, die() is called by all cpus and the system will boot into the dump-capture kernel.
  169. For testing purposes, you can trigger a crash by using "ALT-SysRq-c",
  170. "echo c > /proc/sysrq-trigger or write a module to force the panic.
  171. Write Out the Dump File
  172. =======================
  173. After the dump-capture kernel is booted, write out the dump file with
  174. the following command:
  175. cp /proc/vmcore <dump-file>
  176. You can also access dumped memory as a /dev/oldmem device for a linear
  177. and raw view. To create the device, use the following command:
  178. mknod /dev/oldmem c 1 12
  179. Use the dd command with suitable options for count, bs, and skip to
  180. access specific portions of the dump.
  181. To see the entire memory, use the following command:
  182. dd if=/dev/oldmem of=oldmem.001
  183. Analysis
  184. ========
  185. Before analyzing the dump image, you should reboot into a stable kernel.
  186. You can do limited analysis using GDB on the dump file copied out of
  187. /proc/vmcore. Use the debug vmlinux built with -g and run the following
  188. command:
  189. gdb vmlinux <dump-file>
  190. Stack trace for the task on processor 0, register display, and memory
  191. display work fine.
  192. Note: GDB cannot analyze core files generated in ELF64 format for x86.
  193. On systems with a maximum of 4GB of memory, you can generate
  194. ELF32-format headers using the --elf32-core-headers kernel option on the
  195. dump kernel.
  196. You can also use the Crash utility to analyze dump files in Kdump
  197. format. Crash is available on Dave Anderson's site at the following URL:
  198. http://people.redhat.com/~anderson/
  199. To Do
  200. =====
  201. 1) Provide a kernel pages filtering mechanism, so core file size is not
  202. extreme on systems with huge memory banks.
  203. 2) Relocatable kernel can help in maintaining multiple kernels for
  204. crash_dump, and the same kernel as the system kernel can be used to
  205. capture the dump.
  206. Contact
  207. =======
  208. Vivek Goyal (vgoyal@in.ibm.com)
  209. Maneesh Soni (maneesh@in.ibm.com)
  210. Trademark
  211. =========
  212. Linux is a trademark of Linus Torvalds in the United States, other
  213. countries, or both.