Converting RHEL 8.6 VM image to VHD
Pre-requisites:
The boot options of the source VMs are BIOS or UEFI. Use the standard partitions rather than a logical volume manager (LVM), which is the default for many installations.
Use the persistent naming (file system label or UUID) in
fstabconfiguration.Ensure that the operating system is installed on the first disk of the source VM. Do not configure a swap partition on the operating system disk.
We recommend that the network interface in the source VM uses DHCP and enabled on start.
See Prepare a Red Hat-based virtual machine for Azure
To convert the RHEL 8.6 VM image to VHD
- Install Hyper-V device drivers and rebuild the
initramfsimage file.Check if the Hyper-V drivers (hv_netvsc, hv_storvsc, hv_vmbus) are installed or not.
lsinitrd | grep hv
If they are not installed, perform the following steps.
Back up the previous
initramfsimage file.cd /boot cp initramfs-`uname -r`.img initramfs-`uname -r`.img.bak
Create a file
hv.confunder the directory/etc/dracut.conf.d. Add the following driver parameters to thehv.conffile.add_drivers+=" hv_vmbus " add_drivers+=" hv_netvsc " add_drivers+=" hv_storvsc " add_drivers+=" nvme "
Note:
Add the spaces between the quotes and the driver name.
Create new initial ramdisk images with new modules.
dracut -f -v -N -regenerate-all
Check if the new modules exist in new initial ramdisk images.
lsinitrd | grep -i hv
- Rename the network interface to the name eth0 and enable the NIC on boot.
Azure Linux VMs use traditional NIC names by default.
In the network interface configuration file, configure ONBOOT=yes.
For example,
mv /etc/sysconfig/network-scripts/ifcfg-ens192 /etc/sysconfig/network-scripts/ifcfg-eth0 sed -i 's/ens192/eth0/g' /etc/sysconfig/network-scripts/ifcfg-eth0
- Regenerate the
grub.cfgfor the kernel boot options.To use the traditional NIC names in the file
/etc/default/grub, change the line GRUB_CMDLINE_LINUX="xxxxxxx" to GRUB_CMDLINE_LINUX="xxxxxxx net.ifnames=0"Remove the following parameters if they exist: rhgb quiet crashkernel=auto
Regenerate the
grub.cfgfile.On a BIOS-based computer: grub2-mkconfig -o /boot/grub2/grub.cfg
On a UEFI-based computer: grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
- Perform a new full backup of the source VM.
- Prepare the image sharing server and configure the image sharing feature with azure account.
- Import the backup image and perform the conversion.
- Verify the converted VHD files.
In the Azure web portal:
Create a disk with the converted .vhd file.
Create a VM with the previous disk.
Navigate to Disks > Created disk > Create VM. With default Networking & Disks & Management settings, enable the boot diagnostics.
Log in to the converted VM through SSH.