Sponsored Content
Full Discussion: simulating kernel panic
Top Forums UNIX for Dummies Questions & Answers simulating kernel panic Post 302402602 by pludi on Wednesday 10th of March 2010 08:05:19 AM
Old 03-10-2010
Create and load a minimal module calling the kernels panic() function, eg for Linux (from Linux Crash HOWTO)
Code:
$ cat > panic.c <<EOF
// ### panic.c ###########################

#define __KERNEL__
// # MODULE 

# include init_module(void)

int init_module (void)
{
    panic(" panic has been called");
    return 0;
}
EOF
$ cc -c -I/usr/src/linux/include panic.c
$ insmod panic.o

Note: there's a bug included here on purpose in case anyone wants to try this. The purpose is simply that one shouldn't copy and paste possibly dangerous code without thinking.

---------- Post updated at 14:05 ---------- Previous update was at 13:04 ----------

OK, I should have taken a look at the timestamp of that How-To. Here's a current version for modern kernels (again, with easy to spot bug, and lots of thanks to this page):
Code:
// panic.c
#include <linu/module.h>

static int __init panic_init_module(void) {
    panic(" panic has been called");
}

module_init(panic_init_module);
MODULE_LICENSE("GPL");

Code:
# Makefile
# Intendations have to be tabs, not spaces
UNAME := $(shell uname -r)
KERNEL26 := 2.6
KERNELVERSION := $(findstring $(KERNEL26),$(UNAME))

ifeq ($(KERNELVERSION),2.6)

obj-m := panic.o

INCLUDE := -I/usr/include/asm/
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

all::
	$(MAKE) -C $(KDIR) $(INCLUDE) SUBDIRS=$(PWD) modules
 
else

TARGET := panic
INCLUDE := -I/lib/modules/`uname -r`/build/include -I/usr/include/asm/
CFLAGS := -O2 -Wall -DMODULE -D__KERNEL__ -DLINUX
CC := gcc

all:: ${TARGET}.o

${TARGET}.o: ${TARGET}.c
	$(CC) $(CFLAGS) ${INCLUDE} -c ${TARGET}.c
 
endif

Run it using
Code:
insmod ./panic.o # Kernel 2.4
insmod ./panic.ko # Kernel 2.6

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

RH 7.3 Kernel Panic.

I've installed rh 7.3 a fewday ago and I'm trying to boot it and I get this" Kernel panic: no init found. try passing init=options to kernel" ????? What do I do. Thanks. F,Ruiz. (2 Replies)
Discussion started by: ruizf
2 Replies

2. UNIX for Dummies Questions & Answers

kernel panic

hello :-) I have one problem with my LiLO... I installed PLD Linux on my computer but when it boots, the last thing I can see is: request_module Root fs not mounted VFS: Cannot open root device 03:01 Kernel panic: VFS: unable to mount root fs on 03:01 and the system stops :-( what... (1 Reply)
Discussion started by: pgas
1 Replies

3. Linux

kernel panic

I have compiled kernel version 2.6.12 in my linux box mandrake 10.1. I have followed www.digitalhermit.com/linux/Kernel-Build-HOWTO.html instructions. I have copied .config file from /usr/src/linux and lightly modified it (only the processor type) by xconfig. I have compiled the source and modules.... (3 Replies)
Discussion started by: Davide71
3 Replies

4. Linux

Kernel panic - not syncing: cannot execute a PAE-enabled kernel on PAE-less CPU

ok so I just installed fedora core 6 on my dell inspiron 700m and I go to boot into linux and I get this error. Has anyone seen this before? I also had XP Pro and Vista installed on this pc prior to putting fedora core 6 on the machine. I'm trying to setup a triple boot system. Please Help... (2 Replies)
Discussion started by: dave043
2 Replies

5. Linux

kernel panic on RHEL3

hello all, please, help! we suffered out of power today and one of our Linux boxes cannot boot properly: .. hda set_driver_speed_status error 0X04 VFS: Unable to mount root fs on 00:00 ... the only thing that i can do - is boot in the rescue mode. i've already added noinitrd to... (2 Replies)
Discussion started by: MarGur
2 Replies

6. Red Hat

Kernel Panic problem

Hi all, When i load my block device driver in Fedoracore10 kernel 2.6.27. i got this type of error kernel panic - not syncing : Fatal exception in interrupt. I am unable to save the log file.... Can any one help me..... regards sundar (4 Replies)
Discussion started by: sundhar
4 Replies

7. UNIX for Dummies Questions & Answers

Kernel 3.0 giving me panic :)

I was very exited to try out new kernel version so i decided to give it a try. http://www.conceivablytech.com/7683/products/linux-torvalds-approves-linux-3-0-rc1 So i downloaded the kernel 3.0-rc1 from The Linux Kernel Archives It was my first kernel compilation everything went smooth... (1 Reply)
Discussion started by: pinga123
1 Replies

8. UNIX for Advanced & Expert Users

what does the kernel panic mean?

Hi, all: How should I obtain the reason of kernel panic? How should I debug the program which result in a kernel panic? What can I get from the panic information? li, kunlun (3 Replies)
Discussion started by: liklstar
3 Replies

9. SCO

Kernel Panic

Hello when i booting my SCO Server I become this Message PLS can anyone help me? Cheers Christoph (1 Reply)
Discussion started by: cga
1 Replies

10. Red Hat

Kernel panic-not syncing

dear experts linux i am using RHEL 5.5 run on a physical server. i am front of a big trouble, the Rhel can't run correctly , it show me this error message in black screen: reading all physical volumes. this my take a while .. found volume group "VolGroup00" using metadata type lvm2 9... (1 Reply)
Discussion started by: wassimpb
1 Replies
FINDCHIP(8)															       FINDCHIP(8)

NAME
findchip - checks the FIR chipset. SYNOPSIS
findchip [ -d dongle ] [ -v ] [ -l ] [ <chip1 .. chipN> ] [ -h ] OPTIONS
-d enables debug output -v be verbose -l lists supported chipsets -h prints help message DESCRIPTION
findchip checks the FIR chipset. findchip must be run as root or installed setuid root, as it requires root privileges. EXAMPLES
N.N. DIAGNOSTICS
N.N. BUGS
N.N. SEE ALSO
irattach(8), irdaping(8), irdadump(8), findchip(8), irpsion5(8), modprobe(8) Linux/IrDA Project http://irda.sourceforge.net -*- Linux/IrDA-Tutorial http://www.hpl.hp.com/personal/Jean_Tourrilhes/IrDA/index.html -*- Infrared-HOWTO http://tuxmobil.org/howtos.html -*- Infrared-Hardware-Survey http://tuxmobil.org/ir_misc.html AUTHOR
This manual page is written by Werner Heuser <wehe@tuxmobil.org>. It is based on the READMEs from irda-utils by the Linux/IrDA Project and the Linux/IrDA-Tutorial. COPYRIGHT
Copyright (c) 2001 Werner Heuser Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. 03 July 2006 FINDCHIP(8)
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy