To obtain more (core dump) from a Xen or KVM virtual machine using virsh
, follow these steps:
-
Enable Crashkernel in GRUB (for CentOS/RHEL):
For CentOS or Red Hat Enterprise Linux (RHEL), you'll need to enable crash kernel. Edit the
/etc/default/grub
file and add thecrashkernel
parameter. For example:makefile
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet crashkernel=auto"
Then, update GRUB:
-
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot the system for the changes to take effect.
-
Verify Kernel and Kexec-tools:
Ensure that you have
kexec-tools
and a suitablekernel-debug
package installed on your system.lua
sudo yum install kexec-tools kernel-debug
Verify that the kexec
service is enabled and running:
-
sudo systemctl enable kexec-reboot sudo systemctl start kexec-reboot
-
Crash the Virtual Machine:
Simulate a kernel crash within the virtual machine. You can do this by running the following command inside the virtual machine:
-
echo c > /proc/sysrq-trigger
-
Monitor for Crash Event:
Back on the hypervisor, monitor for the crash event using
dmesg
:Perl -
dmesg | grep "crash"
You should see messages indicating a crash event.
-
Capture more with
virsh
:Use
virsh
to capture the more:javascript -
sudo virsh dump <domain_name> /path/to/save/vmcore
Replace
<domain_name>
with the name of your virtual machine. -
Analyzing the more:
You can use tools like
crash
orgdb
to analyze the vmcore. Installcrash
if it's not already installed:
sudo yum install crash
Then use crash
with the vmcore file:
-
sudo crash /path/to/save/vmcore /usr/lib/debug/lib/modules/$(uname -r)/vmlinux
Use the
bt
commandcrash
to get a backtrace and analyze the crash.
Please note that obtaining a vmcore and analyzing it requires some expertise in debugging kernel-related issues. Make sure to back up important data and configurations before attempting any of these steps, as crashing a system and capturing a VMcore can potentially lead to data loss or system instability. If you're unsure, consider seeking assistance from experienced system administrators or support channels.