Hello,

yesterday I had the problem that a openwrt box (x86) has many processes with 
status D and reboot (even reboot -f) does not work. By default sysrq is not 
enabled in kernel and cant be made as module.

After some research someone in #openwrt got the idea to create a kernel panic 
(which works if automatic reboot on kernel panic is enabled, sysctl -n 
kernel.panic must have a value > 0) via a module described at the page here 
(http://www.unix.com/unix-dummies-questions-answers/131850-simulating-kernel-panic.html).

I created a package which builds the kernel module panic.ko and after upload 
and insmod it and the box finally did a reboot.

I think this module could be useful if no reboot works/sysrq not enabled 
because it can be created after image creation and works with simple 
upload/insmod.

The patch for the package is attached.


With best regards

Christoph
-- 
Linux User Group Wernigerode
http://www.lug-wr.de/
diff -burN package2/kernel-panic/Makefile package/kernel-panic/Makefile
--- package.old/kernel-panic/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ package/kernel-panic/Makefile	2011-12-22 08:52:27.267271121 +0100
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2008 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=kernel-panic
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/kernel-panic
+  SUBMENU:=Other modules
+  TITLE:=Kernel Panic module
+  DEPENDS:=@LINUX_2_6
+  FILES:=$(PKG_BUILD_DIR)/panic.$(LINUX_KMOD_SUFFIX)
+  KCONFIG:=
+endef
+
+define KernelPackage/kernel-panic/description
+  Kernel module to generate a kernel panic
+endef
+
+EXTRA_KCONFIG:= \
+	CONFIG_KERNEL_PANIC=m
+
+EXTRA_CFLAGS:= \
+	$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
+	$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
+
+MAKE_OPTS:= \
+	ARCH="$(LINUX_KARCH)" \
+	CROSS_COMPILE="$(TARGET_CROSS)" \
+	SUBDIRS="$(PKG_BUILD_DIR)" \
+	EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+	$(EXTRA_KCONFIG)
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+	$(CP) ./src/* $(PKG_BUILD_DIR)/
+endef
+
+define Build/Compile
+	$(MAKE) -C "$(LINUX_DIR)" \
+		$(MAKE_OPTS) \
+		modules
+endef
+
+$(eval $(call KernelPackage,kernel-panic))
diff -burN package.old/kernel-panic/src/Kconfig package/kernel-panic/src/Kconfig
--- package.old/kernel-panic/src/Kconfig	1970-01-01 01:00:00.000000000 +0100
+++ package/kernel-panic/src/Kconfig	2011-12-22 08:47:30.879261754 +0100
@@ -0,0 +1,2 @@
+config KERNEL_PANIC
+	tristate "Kernel Panic module"
diff -burN package.old/kernel-panic/src/Makefile package/kernel-panic/src/Makefile
--- package.old/kernel-panic/src/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ package/kernel-panic/src/Makefile	2011-12-22 08:54:11.959274430 +0100
@@ -0,0 +1 @@
+obj-${CONFIG_KERNEL_PANIC}	+= panic.o
diff -burN package.old/kernel-panic/src/panic.c package/kernel-panic/src/panic.c
--- package.old/kernel-panic/src/panic.c	1970-01-01 01:00:00.000000000 +0100
+++ package/kernel-panic/src/panic.c	2011-12-21 22:57:45.000000000 +0100
@@ -0,0 +1,10 @@
+// panic.c
+#include <linux/module.h>
+
+static int __init panic_init_module(void) {
+    panic(" panic has been called");
+}
+
+module_init(panic_init_module);
+MODULE_LICENSE("GPL");
+

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to