Converting SLES 15 SP4 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.
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
- Check that the network interface name is eth0. Ensure that the network interface is using DHCP, and it is enabled on boot.
/etc/sysconfig/network/ifcfg-eth0contains the following:BOOTPROTO='dhcp' STARTMODE='auto'
- Regenerate the
grub.cfgto ensure that console logs are sent to the serial port.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 boot diagnostics.
Log in to the converted VM through SSH.