-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from mariux64/crashkernel-changes
Crashkernel changes
- Loading branch information
Showing
4 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# We are called from initramfs:/init ( /project/admin/initramfs/init ) | ||
# | ||
# Execution environment: | ||
# kernel is the crashkernel | ||
# we are pid 1 | ||
# original root is mounted at / | ||
# root might be mounted "ro" (if we have that in the kernel command line of the crash kernel) | ||
# /dev is mounted (prepopulated by devtmpfs) | ||
# we are executed by bash | ||
|
||
# graphics console is not yet working, because the replaced kernel | ||
# most probably used a framebuffer driver which reinitialized the graphics adapter | ||
# so it no longer runs in a mode initialized by bios/grub. | ||
# These bios-settings can not be restored easily, because this would require | ||
# real mode(true?), which kexec doesn't go through. | ||
# | ||
# We can start the framebuffer driver and get a working console (fbcon) if | ||
# we just load the right driver for the graphics adapter. | ||
# | ||
# However, nouveau currently requires to much memory (because of debugging data) and | ||
# would just create a out of memory kernel panic. | ||
# | ||
#modprobe bochs_drm # DRM Support for bochs dispi vga interface (qemu stdvga) | ||
#modprobe nouveau # nvidia : requires 512MB memory.... | ||
# | ||
# We can't use /dev/kmsg (kernel ring buffer), because it only accepts a very limited | ||
# number of messages per time slot.... | ||
# | ||
#exec >/dev/kmsg 2>&1 | ||
# | ||
# So for now just use our serial console /dev/ttyS1 which hopefully is connected to another system. | ||
# | ||
exec >/dev/ttyS1 2>&1 | ||
|
||
reboot() { | ||
test "$1" && echo "$S $1" | ||
echo "+++++++++++++++++++++++++++++++++++++ reboot in 10s" | ||
sleep 10 | ||
/sbin/reboot -f | ||
} | ||
|
||
free_space() { | ||
local path="$1" | ||
echo $(( $(stat -f -c %a "$path") * $(stat -f -c %S "$path") )) | ||
} | ||
|
||
set -x | ||
echo "+++++++++++++++++++++++++++++++++++++ crash recovery" | ||
|
||
mount -n -t proc proc /proc | ||
mount -n -t sysfs sysfs /sys | ||
|
||
test -e /proc/vmcore || reboot "no crashdump" | ||
core_size=$(stat -c %s /proc/vmcore) | ||
|
||
mount -o remount,rw / / | ||
|
||
if mount -L CRASHDUMP /mnt; then | ||
test -e /mnt/crash.vmcore && rm /mnt/crash.vmcore | ||
if (( $(free_space /mnt) - $core_size > 1024*1024*1024 )); then | ||
echo "+++++++++++++++++++++++++++++++++++++ saving crash dump to CRASHDUMP volume" | ||
cp /proc/vmcore /mnt/crash.vmcore | ||
umount /mnt | ||
else | ||
echo "+++++++++++++++++++++++++++++++++++++ not enough free space on CRASHDUMP volume" | ||
fi | ||
reboot | ||
fi; | ||
|
||
test -e /var/crash.vmcore && rm /var/crash.vmcore | ||
if (( $(free_space /var) - $core_size > 1024*1024*1024 )); then | ||
echo "+++++++++++++++++++++++++++++++++++++ saving crash dump to /var" | ||
cp /proc/vmcore /var/crash.vmcore | ||
else | ||
echo "+++++++++++++++++++++++++++++++++++++ not enough free space in /var" | ||
fi | ||
reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters