Microsoft has released a knowledge base article to deal with a situation where you are unable to use kdump or kexec for Linux virtual machines on Hyper-V.
Consider the following scenario:
- You have a computer that is running a Microsoft Windows operating system with the Hyper-V role installed.
- You install Linux in a Hyper-V virtual machine on the computer.
- You configure kdump on Linux VM which already has the Linux Integration Services drivers either pre-built or manually installed.
In this scenario, if the Linux virtual machine crashes, the core dump of the Linux kernel is not generated.
This issue occurs because Hyper-V is unable to host two simultaneous connections from the same synthetic driver running inside a virtual machine.
When kdump is configured on a Linux virtual machine that is using the Linux Integration Services synthetic storage driver (also known as storvsc), the kexec kernel is configured to use the same driver. If the Linux virtual machine crashes, the synthetic storage driver hosted in kexec kernel attempts to open up a connection to the Hyper-V storage provider. However, Hyper-V fails to establish the new connection because of the pre-existing connection to the same storage driver within the crashed Linux virtual machine. Due to this reason, the kexec kernel is unable to dump core for the crashed Linux virtual machine.
To resolve this issue, configure the kexec kernel with the standard Linux storage driver. This configuration needs to be done after the kdump functionality is enabled on a Linux virtual machine. The basic idea is to turn off the Linux Integration Services storage driver and then enable the standard Linux storage driver inside the kexec kernel by using the prefer_ms_hyper_v parameter at strategic locations.
There are more instructions on the KB article to deal with resolving this issue with each of the supported distros.