Thursday, January 21, 2010

Simulating a Linux Kernel panic

I was once asked a question "How can you simulate Kernel Panic" by someone. Not sure why you would want to do it, probably to test if your monitoring tools report things properly.
Anyways after LOT of googling around I found a link which suggested the way, here's how you can do it (as super user)

echo c > /proc/sysrq-trigger

As soon as you hit the above command, the machine freezes. To check if machine really froze because of a kernel panic check /var/log/messages

Jan 21 17:23:17 chrhel4 kernel: SysRq : Crashing the kernel by request
Jan 21 17:23:17 chrhel4 kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000000
Jan 21 17:23:17 chrhel4 kernel: printing eip:
Jan 21 17:23:17 chrhel4 kernel: c0211ea4
Jan 21 17:23:17 chrhel4 kernel: *pde = 0a578001
Jan 21 17:23:17 chrhel4 kernel: Oops: 0002 [#1]
Jan 21 17:23:17 chrhel4 kernel: SMP
Jan 21 17:23:17 chrhel4 kernel: Modules linked in: parport_pc lp parport autofs4 i2c_dev i2c_core sunrpc cpufreq_powersave ib_srp ib_sdp ib_ipoib md5 ipv6 rdma_ ucm rdma_cm iw_cm ib_addr ib_umad ib_ucm ib_uverbs ib_cm ib_sa ib_mad ib_core dm _mirror dm_mod button battery ac uhci_hcd ehci_hcd snd_ens1371 snd_rawmidi snd_s eq_device snd_pcm_oss snd_mixer_oss snd_pcm snd_timer snd_page_alloc snd_ac97_co dec snd soundcore pcnet32 mii floppy ext3 jbd ata_piix libata mptscsih mptsas mp tspi mptscsi mptbase sd_mod scsi_mod
Jan 21 17:23:17 chrhel4 kernel: CPU: 0
Jan 21 17:23:17 chrhel4 kernel: EIP: 0060:[] Not tainted VLI
Jan 21 17:23:17 chrhel4 kernel: EFLAGS: 00010046 (2.6.9-78.ELsmp)
Jan 21 17:23:17 chrhel4 kernel: EIP is at sysrq_handle_crash+0x0/0x8
Jan 21 17:23:17 chrhel4 kernel: eax: 00000063 ebx: c034d754 ecx: 00000000 edx: 00000000
Jan 21 17:23:17 chrhel4 kernel: esi: 00000063 edi: 00000000 ebp: 00000000 esp: c99e2f5c
Jan 21 17:23:17 chrhel4 kernel: ds: 007b es: 007b ss: 0068
Jan 21 17:23:17 chrhel4 kernel: Process bash (pid: 11979, threadinfo=c99e2000 ta sk=dbf592f0)
Jan 21 17:23:17 chrhel4 kernel: Stack: c021203c c0301e91 c03032a2 00000246 00000 006 00000002 e6985880 00000002
Jan 21 17:23:17 chrhel4 kernel: c99e2fac c018e504 c033f4c0 c015c88f c99e2 fac b7ce8000 e6985880 fffffff7
Jan 21 17:23:17 chrhel4 kernel: b7ce8000 c99e2000 c015c959 c99e2fac 00000 000 00000000 00000000 00000001
Jan 21 17:23:17 chrhel4 kernel: Call Trace:
Jan 21 17:23:17 chrhel4 kernel: [] __handle_sysrq+0x62/0xd9
Jan 21 17:23:17 chrhel4 kernel: [] write_sysrq_trigger+0x23/0x29
Jan 21 17:23:17 chrhel4 kernel: [] vfs_write+0xb6/0xe2
Jan 21 17:23:17 chrhel4 kernel: [] sys_write+0x3c/0x62
Jan 21 17:23:17 chrhel4 kernel: [] syscall_call+0x7/0xb
Jan 21 17:23:17 chrhel4 kernel: Code: 11 c0 c7 05 10 6d 46 c0 00 00 00 00 c7 05 38 6d 46 c0 00 00 00 00 c7 05 2c 6d 46 c0 6e ad 87 4b 89 15 28 6d 46 c0 e9 a4 f9 f1 ff 05 00 00 00 00 00 c3 e9 a2 bc f4 ff e9 6b 07 f5 ff 85 d2 89
Jan 21 17:23:17 chrhel4 kernel: <0>Fatal exception: panic in 5 seconds

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home