Preparing a Linux VM for Conversion from VMware to Hyper-V

Summary

What's needed for this conversion is the addition of kernel modules that support the network and storage systems in Hyper-V. These modules are available for all current supported Linux systems but may not be installed in the initramfs used by the kernel during the boot process. If these modules are not present when a VM boots in Hyper-V the kernel will not be able to transition from the initramfs to complete the boot process.

NOTE:  If you are viewing this information on the OIT web site, we recommend visiting the ServiceNow knowledge article for the correct formatting:  https://duke.service-now.com/kb_view.do?sysparm_article=KB0038999

NOTE: If your system is Legacy Booted (BIOS) Then you only need to make sure you have relevant kernel modules installed as outlined below. You do not need to be concerned with UEFI configuration mentioned.

For RHEL Based systems (RHEL, Almalinux)

Check to see if you have the Hyper-V modules already in your initial ram disk

lsinitrd /boot/initramfs-$(uname -r).img | grep -E 'hv_(vmbus|netvsc|storvsc)'

N.B.: This checks based on running kernel. If you have updated your kernel but not rebooted yet the results will be inaccurate.

There should be THREE results from that grep hv_vmbus, hv_netvsc, and hv_storvsc For example (from Almalinux 9):

-rw-r--r-- 1 root root 60012 Mar 31 07:51 usr/lib/modules/5.14.0-570.19.1.el9_6.x86_64/kernel/drivers/hv/hv_vmbus.ko.xz -rw-r--r-- 1 root root 57492 Mar 31 07:51 usr/lib/modules/5.14.0-570.19.1.el9_6.x86_64/kernel/drivers/net/hyperv/hv_netvsc.ko.xz -rw-r--r-- 1 root root 19236 Mar 31 07:51 usr/lib/modules/5.14.0-570.19.1.el9_6.x86_64/kernel/drivers/scsi/hv_storvsc.ko.xz

If you do NOT have those three modules you will need to add them prior to your system being converted.

Adding required Hyper-V modules and rebuilding your initial RAM disk

Add the modules:

echo 'add_drivers+=" hv_vmbus hv_netvsc hv_storvsc "' > /etc/dracut.conf.d/hyperv-drivers.conf

Rebuild your initial RAM disk

dracut --regenerate-all -f -v

Verify that the 3 modules were added:

lsinitrd /boot/initramfs-$(uname -r).img | grep -E 'hv_(vmbus|netvsc|storvsc)' Adding required Hyper-V daemons

These daemons communicate VM information to the Hyper-V management system. Install before conversion. If you install after conversion, an additional reboot is required.

dnf install hyperv-daemons
For Debian Based Systems (Debian, Ubuntu)

N.B.: If you're using pure Debian be sure to confirm updated grub configuration below.

N.B.: Be sure to note the addition of hyper-v daemons on Debian and Ubuntu

Check to see if you have the Hyper-V modules already in your initial ram disk

lsinitramfs /boot/initrd.img-$(uname -r) | grep -E 'hv_(vmbus|netvsc|storvsc)'

N.B.: This checks based on running kernel. If you have updated your kernel but not rebooted yet the results will be inaccurate.

There should be THREE results from that grep hv_vmbus, hv_netvsc, and hv_storvsc For example (from Ubuntu 24.04):

usr/lib/modules/6.8.0-78-generic/kernel/drivers/hv/hv_vmbus.ko.zst usr/lib/modules/6.8.0-78-generic/kernel/drivers/net/hyperv/hv_netvsc.ko.zst usr/lib/modules/6.8.0-78-generic/kernel/drivers/scsi/hv_storvsc.ko.zst

If you do NOT have those three modules you will need to add them prior to your system being converted.

Adding required Hyper-V modules and rebuilding your initial RAM disk

Add the modules by editing the file /etc/initramfs-tools/modules to contain the following 3 lines.

hv_vmbus hv_netvsc hv_storvsc

Rebuild your initial RAM disk:

mkinitramfs -k -o /boot/initrd.img-$(uname -r)

Verify that the 3 modules were added to your initial RAM disk:

lsinitramfs /boot/initrd.img-$(uname -r) | grep -E 'hv_(vmbus|netvsc|storvsc)'

Adding Hyper-V daemons

These daemons communicate VM information to the Hyper-V management system. Install before conversion. If you install after conversion, an additional reboot is required.

For Debian:

apt-get install hyperv-daemons

For Ubuntu:

apt-get install linux-cloud-tools-virtual

Check to see if grub is configured in the fallback removable media path:

# stat /boot/efi/EFI/BOOT/BOOTX64.EFI

If that file exists you should be fine. It likely will not exist with default installation options.

Installing grub to removable media path (required for Hyper-V EFI implementation):

# echo 'grub-efi-amd64 grub2/force_efi_extra_removable boolean true' | debconf-set-selections -v -u # apt-get install -y --reinstall grub-efi-amd64

This will toggle that option and will reinstall grub in both places. Now you can confirm that it worked by verifying that /boot/efi/EFI/BOOT/BOOTX64.EFI exists.

Verify netplan configuration:

This is a rare occurrence that we've so far only seen with custom installations of Ubuntu systems.

If your network interfaces are using the Consistent Network Device Naming scheme (enXYYY) rather than the legacy scheme (ethX) before conversion you may need to plan to connect to the console of the system if the conversion fails and ensure that the legacy scheme device names are in your netplan configuration. It's not recommended to do this before you schedule conversion as you may have trouble if you need to fall back to the vmware instance of your system for other reasons.

References:

Article number: KB0038999

Valid to: November 20, 2026