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/grubfile and add thecrashkernelparameter. 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.cfgReboot the system for the changes to take effect.
-
Verify Kernel and Kexec-tools:
Ensure that you have
kexec-toolsand a suitablekernel-debugpackage 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
virshto capture the more:javascript -
sudo virsh dump <domain_name> /path/to/save/vmcoreReplace
<domain_name>with the name of your virtual machine. -
Analyzing the more:
You can use tools like
crashorgdbto analyze the vmcore. Installcrashif 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)/vmlinuxUse the
btcommandcrashto 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.
Dansk