Installing Hyper-V Drivers for Linux VMs

Azure VMs require Hyper-V drivers for the Hyper-V network and storage devices. The instructions for installation vary among vendor types and versions.

The following drivers are required on the source VM:

  • hv_netvsc.ko

  • hv_storvsc.ko

  • hv_vmbus.ko

On the source VM, recut the initramfs with required kernel drivers for Hyper-V hardware on the source machine. These operations do not cause any disruption to the source machine.

Before You Begin

The following procedures describe the minimum requirements for installing Hyper-V drivers. If you require additional details or you have problems during the recovery process, review the instructions in the Microsoft documentation. Generic instructions for all Linux vendors appear on this page, and more vendor-specific instructions appear in the navigation beneath it: Prepare Linux for Imaging in Azure.

Depending on the version of Linux running on the guest VMs, the following factors might cause problems with the destination VM in Azure:

  • CentOS 7.x, RHEL 7.x and more recent versions: Missing required drivers prevents the target VMs from starting.

  • CentOS 7.x, RHEL 7.x and more recent versions: Incorrect Classless Inter-Domain Routing (CIDR) subnet range configuration makes VMs unreachable.

  • RHEL 5.x: Boot device that is configured for device or label-based mount prevents the target VMs from starting.

  • Debian 7.x and more recent versions: Missing required drivers prevents the target VMs from starting.

  • SUSE: Linux VMs do not start or are unreachable after recovering to Azure.

  • Ubuntu 18.x and more recent versions: Missing required drivers prevents the target VMs from starting.

Procedures

CentOS 7.x, RHEL 7.x and More Recent Versions

  1. Check whether required Hyper-V kernel modules are present:

    lsmod | grep -i hv
  2. Identify the current kernel version:

    uname -r
  3. Create a backup of the current initramfs:

    cp /boot/initramfs-<Current_Version>.img /boot/initramfs-<Current_Version>.img.backup

  4. Edit the dracut.conf file:

    vi /etc/dracut.conf
  5. Uncomment the line that contains add-drivers, and then add the following drivers to the line, with spaces separating each module:

    hv_netvsc hv_storvsc hv_vmbus
  6. Go to the boot folder:

    cd /boot
  7. Recut the initramfs:

    dracut -f -v
  8. Verify that the size has changed:

    ls -l
  9. Perform a new full backup of the source VM and repeat the recovery operation.

  10. Verify that the destination VMs start.

RHEL 5.x

RHEL 5.x uses a label-based mount, but Azure requires a UUID-based mount for the boot device.

  1. On the source VMM, modify the /etc/fstab file to change the mounting of the boot volume to be UUID-based.

    The following example shows a label-based mount configuration:

    [root]# cat /etc/fstab.orig
     /dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
     LABEL=/boot             /boot                   ext3    defaults        1 2
     tmpfs                   /dev/shm                tmpfs   defaults        0 0

    The following example shows a UUID-based mount configuration:

    [root]# cat /etc/fstab /dev/VolGroup00/LogVol00 / ext3 defaults 1 1 UUID=<UUID_value> /boot ext3 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0

    where <UUID_value> represents the UUID for the destination VM.

  2. Perform a new full backup of the source VM and repeat the recovery operation.

  3. Verify that the destination VMs start.

Debian 7.x and More Recent Versions

  1. Check whether required Hyper-V kernel modules are present:

    lsmod | grep -i hv
  2. Identify the current kernel version:

    uname -r
  3. Create a backup of the current initrd:

    cp /boot/initrd.img-<Current_Version> /boot/initrd.img-<Current_Version>.backup 
  4. Edit the initramfs module file:

    vi /etc/initramfs-tools/modules
  5. Add the following drivers in the file, with each line on a separate line:

    hv_netvsc
    hv_storvsc
    hv_vmbus
  6. Go to boot folder:

    cd /boot
  7. Update the initramfs image for current version to include new driver modules:

    sudo update-initramfs -u -k `uname -r`
  8. Verify that the size has changed:

    ls -l
  9. Reboot your system:

    sudo reboot
  10. Perform a new full backup of the source VM and repeat the recovery operation.

  11. Verify that the destination VMs start.

SUSE Linux

Depending on the SUSE OS version, the commands might vary.

  1. Identify the current kernel version:

    uname -r
  2. Check whether required drivers are already a part of the initrd image for the guest VM:

    lsinitrd | grep -i hv
  3. Go to the boot folder:

    cd /boot
  4. Take a backup of the initrd image:

    cp initrd-$(uname -r) initrd-$(uname -r).backup
  5. Insert the drivers and recut the initrd image:

    mkinitrd -v -m "hv_vmbus hv_netvsc hv_storvsc" -f /boot/initrd-$(uname -r) $(uname -r)
  6. Check whether Hyper-V kernel modules got installed succesfully:

    lsinitrd | grep -i hv
  7. Verify that the size has changed:

    ls -l
  8. Perform a new full backup of the source VM and repeat the recovery operation.

  9. Verify that the destination VMs start.

Ubuntu 18.x and More Recent Versions

  1. Check whether required Hyper-V kernel modules are present:

    lsmod | grep -i hv
  2. Create a backup of the current initrd:

    cp /boot/initrd.img /boot/initrd.img.backup
  3. Update the operating system to the latest Azure-tailored kernel and install Azure Linux tools (including Hyper-V dependencies):

    sudo apt update
    sudo apt install linux-azure linux-image-azure linux-headers-azure linux-tools-common linux-cloud-tools-common linux-tools-azure linux-cloud-tools-azure
    sudo apt full-upgrade
    sudo reboot
  4. Perform a new full backup of the source VM and repeat the recovery operation.

  5. Verify that the destination VMs start.

Loading...