ArticlesRocky Linux

Migrating a Rocky Linux KVM VM to Microsoft Azure

Introduction

This article provides step-by-step instructions for migrating a local Rocky Linux 8.10 KVM virtual machine to Microsoft Azure using Azure Migrate and the Azure Site Recovery replication appliance.

The migration process involves preparing your source VM, setting up the necessary Azure infrastructure, configuring the replication appliance, and performing the actual migration.

Problem

Organizations need to migrate on-premises virtual machines often running on KVM to Microsoft Azure for cloud adoption, disaster recovery, or infrastructure modernization purposes. The amount of VMs to migrate to the cloud can range in the thousands and services such as Azure Migrate help to make the transition smoother.

The migration process requires specific configuration steps for both the source VM and Azure environment to ensure successful replication and migration.

Symptoms

You have a fleet of Rocky Linux VMs running on KVM that needs to be migrated to Azure.

The VM requires migrating to the cloud whilst maintaining its configuration and data integrity.

Resolution

Prerequisites

Rocky Linux

  • A Rocky Linux 8.10 KVM VM (as an example, but Rocky Linux 9 and Rocky Linux 10 are also fine) with a minimum of:

  • 4096 MB of RAM

  • 2 vCPUs

  • 16GB of disk space

  • SCSI disk type

Windows Server

  • A Windows Server 2022 VM on KVM, also with a minimum of:

  • 16GB of RAM

  • 8 vCPUs

  • 700GB of disk space (the replication appliance requires at least 600GB of disk space cache available)

Please check Azure Appliance requirements

Azure

  • An active Azure subscription with appropriate permissions

  • Access to the Azure Portal

Step 1: prepare the source Rocky Linux VM

  • Deploy a local Rocky Linux 8.10 KVM and upgrade all packages.

  • Provide the VM with 4096 MB of RAM, 2 vCPUs and 16GB of disk as listed in the Prerequisites.

  • Change the bus type to SCSI before installing the OS. This is performed under Hardware --> VirtIO Disk 1 --> Disk bus and changing the bus type to SCSI

  • In the KVM VM, enable the following firewall ports for communication with the replication appliance:

sudo firewall-cmd --add-port=135/tcp --permanent
sudo firewall-cmd --add-port=443/tcp --permanent
sudo firewall-cmd --add-port=1024-65535/tcp --permanent
sudo firewall-cmd --add-port=443/udp --permanent
sudo firewall-cmd --reload
  • Shut down the VM

  • Remove the SATA CDROM 1 hardware.

  • Change the SCSI Disk 1 XML to the following:

<disk type="file" device="disk">
  <driver name="qemu" type="qcow2"/>
  <source file="/PATH/TO/<YOUR_QCOW2_IMAGE>.qcow2"/>
  <target dev="sda" bus="scsi"/>
  <address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
  • Power up the VM and verify it boots successfully.

Step 2: prepare the Windows Server 2022 VM for the replication appliance

  • Deploy a Windows Server 2022 VM on KVM with 16GB of RAM, 8 vCPUs and 700GB of disk space. Choose the Standard Desktop installation.

  • Set a password and then login to the Windows Server.

Step 3: configure the Azure virtual network

  • Go to Virtual Networks in the Azure Portal and click Create

  • Under Basics, select your Resource Group, enter a Virtual network name and choose your region.

  • For Security, leave all options at default and click Next

  • For IP addresses, leave all options at default and click Next

  • In Tags, apply your tags and click Next

  • Click Create

Step 4: set up the Azure Migrate project

  • Go to Azure Migrate --> Servers, databases and web apps and select Create project

  • Add your Resource Group, Project Name, Geography and click Create

  • Under Assessment tools, go to Migration and modernization (**note, do not use the "Azure Migrate: Discovery and assessment" option **) and click Discover

  • For Where do you want to migrate to?, choose Azure VM

  • For Are your machines virtualized?, select Physical or other (AWS, GCP, Xen, etc.)

  • Select your Target region

  • Check the box that says Confirm that the target region for migration is "<REGION>"

  • Click Create resources

  • Return to Discover and specify the same options for Where do you want to migrate to?, Are your machines virtualized? and Target region

  • For Experience type, select Simplified Experience (Recommended)

  • Go to Step 2 and click Generate key to create your ASR replication appliance key

  • Store this key in a safe location for later use in the process.

Step 5: Install and Configure the Replication Appliance

  • Download the installer from the provided link to your Windows Server 2022 VM

  • Extract the zip file's contents.

  • Open a PowerShell window as an Administrator, navigate to the folder and run .\DRInstaller.ps1

  • If you receive an error about the script not being digitally signed, run this command instead and modify the path for your folder's location:

powershell -ExecutionPolicy Bypass -File "C:\Users\Administrator\Downloads\DRAppliance\DRAppliance\DRInstaller.ps1"
  • Go to the desktop and open the shortcut to the Microsoft Azure Appliance Configuration Manager

  • Click Continue through the Set up prerequisites, Appliance components and Select Replication appliance connectivity steps.

  • Under Register with Recovery Services vault, provide a friendly name and the ASR replication appliance key you generated earlier.

  • Click Login and then Copy code and Login

  • Log in with your Azure credentials.

  • Once the appliance is registered, click Continue

  • Under Configure vCenter details, check I do not have vCenter Server/vSphere ESXi server. I'll protect my servers by manually discovering them using IP addresses. and press Continue

  • For Provide physical server credentials, click Add credentials

  • Select the Operating System as Linux, provide a friendly name and input the root user's credentials.

  • Click Add

  • Under Provide physical server information, click Add server

  • Input the IP address of your Rocky Linux 8.10 VM and click Add

  • Click Continue and wait approximately 30 minutes for the process to complete.

  • Verify you see a green checkmark with Completed appliance configuration successfully.

Step 6: configure replication

  • In the Azure Portal, go to Azure Migrate: Server Migration and click Replicate

  • Leave other options as default and for Are your machines virtualized? choose Physical or other (AWS, GCP, Xen, etc.)

  • From On-premises appliance, choose your appliance and select Continue

  • For Basics --> Guest credentials, choose your Rocky Linux 8.10 VM's guest credentials.

  • Select the checkbox next to your VM when it appears and click Next

  • For Target settings, choose your Virtual network created earlier, leave other options as default and click Next

  • At Compute, click Next

  • For Disks --> Disk Type, select Standard SSD (or another disk type of your choice) and click Next

  • For Tags, add your tags and click Next

  • At Review + Start replication, choose Replicate

Step 7: perform the migration

  • Skip the Test migration step if not needed and go to Migrate

  • Leave the default Azure VM option and click Continue

  • Select the VM you want to migrate and leave Yes, shutdown virtual machines(Ensures no data loss) checked.

  • Click Migrate

Step 8: configure network access for the migrated VM

  • Once complete, your local VM will shut down.

  • Go to Virtual Machines in Azure Portal to access your newly migrated VM

  • Navigate to your newly created VM under Virtual Machines, then Networking and then Network settings

  • Click Add network security group

  • When the network security group is created, click Create port rule and select Inbound port rule

  • Specify an IP address, source and destination ports, the protocol to use, and the Action to allow or deny traffic.

  • Click Save

  • For temporary SSH access testing, you can set Source to Any, Source port ranges to *, Destination port ranges to 22. Please check with your Security Team on how ports, protocols and IPs should be set up first for best security practices.

  • Click Add

Step 9: configure a public IP address

  • Under Networking --> Network settings, check that a Public IP address is listed.

  • If not present, click (Configure) and click on your NIC listed in the table. An example NIC name is nic-rocky-linux-810-00-ipconfig

  • Check the box next to Associate public IP address and click Save

  • Refresh the IP configurations page to see the Public IP Address

  • Go to your VM, then Connect and select Native SSH

  • ssh into your machine with the root account or another configured account.

Notes

The migration process may take considerable time depending on the size of your source VM and network bandwidth.

Always perform a test migration before executing the final migration in production environments.

References & related articles

Set up the appliance through PowerShell

Azure Site Recovery Appliance Installer