diff options
Diffstat (limited to 'meta/recipes-kernel')
-rw-r--r-- | meta/recipes-kernel/kexec/kexec-tools.inc | 5 | ||||
-rwxr-xr-x | meta/recipes-kernel/kexec/kexec-tools/kdump | 163 | ||||
-rw-r--r-- | meta/recipes-kernel/kexec/kexec-tools/kdump.conf | 18 | ||||
-rw-r--r-- | meta/recipes-kernel/kexec/kexec-tools_2.0.10.bb | 8 |
4 files changed, 193 insertions, 1 deletions
diff --git a/meta/recipes-kernel/kexec/kexec-tools.inc b/meta/recipes-kernel/kexec/kexec-tools.inc index 7797a25738..758a3a78b8 100644 --- a/meta/recipes-kernel/kexec/kexec-tools.inc +++ b/meta/recipes-kernel/kexec/kexec-tools.inc | |||
@@ -8,7 +8,10 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=ea5bed2f60d357618ca161ad539f7c0a \ | |||
8 | file://kexec/kexec.c;beginline=1;endline=20;md5=af10f6ae4a8715965e648aa687ad3e09" | 8 | file://kexec/kexec.c;beginline=1;endline=20;md5=af10f6ae4a8715965e648aa687ad3e09" |
9 | DEPENDS = "zlib xz" | 9 | DEPENDS = "zlib xz" |
10 | 10 | ||
11 | SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.gz" | 11 | SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.gz \ |
12 | file://kdump \ | ||
13 | file://kdump.conf \ | ||
14 | " | ||
12 | 15 | ||
13 | PR = "r1" | 16 | PR = "r1" |
14 | 17 | ||
diff --git a/meta/recipes-kernel/kexec/kexec-tools/kdump b/meta/recipes-kernel/kexec/kexec-tools/kdump new file mode 100755 index 0000000000..3fb133fb35 --- /dev/null +++ b/meta/recipes-kernel/kexec/kexec-tools/kdump | |||
@@ -0,0 +1,163 @@ | |||
1 | #! /bin/sh | ||
2 | # | ||
3 | # kdump | ||
4 | # | ||
5 | # Description: The kdump script provides the support: | ||
6 | # 1. Load a kdump kernel image into memory; | ||
7 | # 2. Copy away vmcore when system panic. | ||
8 | # | ||
9 | |||
10 | #default | ||
11 | KDUMP_KVER="`uname -r`" | ||
12 | KDUMP_KIMAGE="/boot/bzImage-${KDUMP_KVER}" | ||
13 | KDUMP_CMDLINE="`cat /proc/cmdline`" | ||
14 | KDUMP_CMDLINE_APPEND="kdump_needed maxcpus=1 irqpoll reset_devices" | ||
15 | KDUMP_VMCORE_PATH="/var/crash/`date +"%Y-%m-%d"`" | ||
16 | |||
17 | #get right kernel image | ||
18 | march="`uname -m`" | ||
19 | case ${march} in | ||
20 | x86*|i?86) | ||
21 | ;; | ||
22 | *) | ||
23 | KDUMP_KIMAGE="/boot/uImage-${KDUMP_KVER}" | ||
24 | ;; | ||
25 | esac | ||
26 | |||
27 | KEXEC=usr/sbin/kexec | ||
28 | KEXEC_ARGS="-p" | ||
29 | |||
30 | MAKEDUMPFILE=/usr/bin/makedumpfile | ||
31 | MAKEDUMPFILE_ARGS="-E -d 1" | ||
32 | |||
33 | LOGGER="logger -p info -t kdump" | ||
34 | |||
35 | if [ -f /etc/sysconfig/kdump.conf ]; then | ||
36 | . /etc/sysconfig/kdump.conf | ||
37 | fi | ||
38 | |||
39 | do_check() | ||
40 | { | ||
41 | #check makedumpfile | ||
42 | if [ ! -e ${MAKEDUMPFILE} -o ! -x ${MAKEDUMPFILE} ] ;then | ||
43 | echo "No makedumpfile found." | ||
44 | return 1; | ||
45 | fi | ||
46 | |||
47 | #check kexec | ||
48 | if [ ! -e ${KEXEC} -o ! -x ${KEXEC} ] ;then | ||
49 | echo "No kexec found." | ||
50 | return 1; | ||
51 | fi | ||
52 | |||
53 | #check whether kdump kernel image exists on the system | ||
54 | if [ ! -f ${KDUMP_KIMAGE} ]; then | ||
55 | echo "No kdump kernel image found." | ||
56 | return 1 | ||
57 | fi | ||
58 | } | ||
59 | |||
60 | do_save_vmcore() | ||
61 | { | ||
62 | mkdir -p ${KDUMP_VMCORE_PATH} | ||
63 | echo "Saving a vmcore to ${KDUMP_VMCORE_PATH}." | ||
64 | |||
65 | ${MAKEDUMPFILE} ${MAKEDUMPFILE_ARGS} /proc/vmcore ${KDUMP_VMCORE_PATH}/vmcore-"`date +"%H:%M:%S"`" | ||
66 | # cp --sparse=always /proc/vmcore ${KDUMP_VMCORE_PATH}/vmcore-"`date +"%H:%M:%S"`" | ||
67 | rc=$? | ||
68 | if [ ${rc} == 0 ]; then | ||
69 | ${LOGGER} "Saved a vmcore to ${KDUMP_VMCORE_PATH}." | ||
70 | else | ||
71 | ${LOGGER} "Failed to save vmcore!" | ||
72 | fi | ||
73 | return ${rc} | ||
74 | } | ||
75 | |||
76 | do_start() | ||
77 | { | ||
78 | #check file | ||
79 | do_check | ||
80 | |||
81 | #check whether the running kernel supports kdump. | ||
82 | if [ ! -e /sys/kernel/kexec_crash_loaded ]; then | ||
83 | echo "Kdump isn't supported on the running kernel!!!" | ||
84 | ${LOGGER} "Kdump isn't supported on the running kernel!!!" | ||
85 | return 1 | ||
86 | fi | ||
87 | |||
88 | #check whether kdump kernel image has been loaded | ||
89 | rc=`cat /sys/kernel/kexec_crash_loaded` | ||
90 | if [ ${rc} != 0 ]; then | ||
91 | echo "Kdump is already running."; | ||
92 | ${LOGGER} "Kdump is already running." | ||
93 | return 0 | ||
94 | fi | ||
95 | |||
96 | #check the running kernel cmdline option,insure "crashkenrel=" always set. | ||
97 | grep -q crashkernel= /proc/cmdline | ||
98 | if [ $? != 0 ]; then | ||
99 | echo "Kdump isn't supported on the running kernel,please check boot option!!!" | ||
100 | ${LOGGER} "Kdump isn't supported on the running kernel,please check boot option!!!" | ||
101 | return 1 | ||
102 | fi | ||
103 | |||
104 | #handle kdump cmdline parameters, remove some useless options | ||
105 | kcmdline="" | ||
106 | for x in `cat /proc/cmdline`; do | ||
107 | case $x in | ||
108 | crashkernel*) | ||
109 | ;; | ||
110 | *) | ||
111 | kcmdline="${kcmdline} $x" | ||
112 | ;; | ||
113 | esac | ||
114 | done | ||
115 | |||
116 | KDUMP_CMDLINE="${kcmdline} ${KDUMP_CMDLINE_APPEND}" | ||
117 | |||
118 | #Load the kdump kernel image | ||
119 | ${KEXEC} ${KEXEC_ARGS} "${KDUMP_KIMAGE}" --append="${KDUMP_CMDLINE}" | ||
120 | if [ $? != 0 ]; then | ||
121 | echo "Failed to load kdump kernel!" | ||
122 | ${LOGGER} "Failed to load kdump kernel!" | ||
123 | return 1 | ||
124 | fi | ||
125 | |||
126 | echo "Kdump started up." | ||
127 | ${LOGGER} "Kdump started up." | ||
128 | } | ||
129 | |||
130 | do_stop() | ||
131 | { | ||
132 | ${KEXEC} -p -u 2>/dev/null | ||
133 | if [ $? == 0 ]; then | ||
134 | echo "Kdump has been stopped." | ||
135 | ${LOGGER} "Kdump has been stopped." | ||
136 | else | ||
137 | echo "Failed to stop kdump!" | ||
138 | ${LOGGER} "Failed to stop kdump!" | ||
139 | fi | ||
140 | } | ||
141 | |||
142 | case "$1" in | ||
143 | start) | ||
144 | if [ -s /proc/vmcore ]; then | ||
145 | do_save_vmcore | ||
146 | reboot | ||
147 | else | ||
148 | do_start | ||
149 | fi | ||
150 | ;; | ||
151 | restart) | ||
152 | do_stop | ||
153 | do_start | ||
154 | ;; | ||
155 | stop) | ||
156 | do_stop | ||
157 | ;; | ||
158 | *) | ||
159 | echo $"Usage: $0 {start|stop|restart}" | ||
160 | exit 1 | ||
161 | esac | ||
162 | |||
163 | exit $? | ||
diff --git a/meta/recipes-kernel/kexec/kexec-tools/kdump.conf b/meta/recipes-kernel/kexec/kexec-tools/kdump.conf new file mode 100644 index 0000000000..42a2435b96 --- /dev/null +++ b/meta/recipes-kernel/kexec/kexec-tools/kdump.conf | |||
@@ -0,0 +1,18 @@ | |||
1 | #the kdump kernel version string. | ||
2 | #KDUMP_KVER="`uname -r`" | ||
3 | |||
4 | #this will be passed to the kdump kernel as kdump kernel command line, it | ||
5 | #usually comes from /proc/cmdline | ||
6 | #KDUMP_CMDLINE="`cat /proc/cmdline`" | ||
7 | |||
8 | # append arguments to the kdump commandline | ||
9 | #KDUMP_CMDLINE_APPEND="kdump_needed maxcpus=1 irqpoll reset_devices" | ||
10 | |||
11 | #the kernel image for kdump | ||
12 | #KDUMP_KIMAGE="/boot/bzImage-${KDUMP_KVER}" | ||
13 | |||
14 | #Where to save the vmcore | ||
15 | #KDUMP_VMCORE_PATH="/var/crash/`date +"%Y-%m-%d"`" | ||
16 | |||
17 | #the arguments to makedumpfile | ||
18 | MAKEDUMPFILE_ARGS="--dump-dmesg -x /boot/vmlinux-`uname -r`" | ||
diff --git a/meta/recipes-kernel/kexec/kexec-tools_2.0.10.bb b/meta/recipes-kernel/kexec/kexec-tools_2.0.10.bb index ffdb983a41..f21121733f 100644 --- a/meta/recipes-kernel/kexec/kexec-tools_2.0.10.bb +++ b/meta/recipes-kernel/kexec/kexec-tools_2.0.10.bb | |||
@@ -17,6 +17,14 @@ PACKAGES =+ "kexec kdump vmcore-dmesg" | |||
17 | ALLOW_EMPTY_${PN} = "1" | 17 | ALLOW_EMPTY_${PN} = "1" |
18 | RRECOMMENDS_${PN} = "kexec kdump vmcore-dmesg" | 18 | RRECOMMENDS_${PN} = "kexec kdump vmcore-dmesg" |
19 | 19 | ||
20 | FILES_${PN} =+ "${sysconfig}/init.d/kdump ${sysconfig}/sysconfig/kdump.conf" | ||
20 | FILES_kexec = "${sbindir}/kexec" | 21 | FILES_kexec = "${sbindir}/kexec" |
21 | FILES_kdump = "${sbindir}/kdump" | 22 | FILES_kdump = "${sbindir}/kdump" |
22 | FILES_vmcore-dmesg = "${sbindir}/vmcore-dmesg" | 23 | FILES_vmcore-dmesg = "${sbindir}/vmcore-dmesg" |
24 | |||
25 | do_install_append () { | ||
26 | install -d ${D}${sysconfdir}/init.d | ||
27 | install -m 0755 ${WORKDIR}/kdump ${D}${sysconfdir}/init.d/kdump | ||
28 | install -d ${D}${sysconfdir}/sysconfig | ||
29 | install -m 0644 ${WORKDIR}/kdump.conf ${D}${sysconfdir}/sysconfig | ||
30 | } | ||