Linux Virtual Machine Preparation Guide for Protecting Virtual
Total Page:16
File Type:pdf, Size:1020Kb
Linux Virtual Machine Preparation Guide For protecting virtual machines to Azure Version 2.0 Update 0520 Table of Contents ABOUT THIS GUIDE ................................................................................................................. 2 END STATE OPERATIONS GOALS ............................................................................................ 2 HOW TO PREPARE A CENTOS 6X OR REDHAT 6X-BASED VIRTUAL MACHINES ..................... 3 Assumptions .................................................................................................................. 3 Step 1: Modify Grub Options ........................................................................................ 3 Step 2: Configure agetty serial console ......................................................................... 4 Step 3: Add HyperV drivers to the dracut config .......................................................... 4 Step 4: Check to see if Hyper-V modules are loaded .................................................... 5 Step 4: Add persistent rule for Azure Nics .................................................................... 5 Step 5: Creating an ifcfg-eth file for the Azure NIC: ...................................................... 6 HOW TO PREPARE A CENTOS 7X OR REDHAT 7X-BASED VIRTUAL MACHINES ..................... 8 Assumptions .................................................................................................................. 8 Step 1: Modify Grub Options ........................................................................................ 8 Step 2: Adding Hyper-V drivers to the initramfs ........................................................... 9 Step 3: Check to see if Hyper-V modules are loaded .................................................. 10 Step 4: Configuring Networking .................................................................................. 10 Step 5: Creating an ifcfg-eth file for the Azure nic ...................................................... 11 HOW TO PREPARE AN UBUNTU OR DEBIAN-BASED VIRTUAL MACHINE ............................14 Step 1: Create an Azure Netplan profile ..................................................................... 14 HOW ZERTO ASSIGNS STATIC IP ADDRESSES TO VMS IN AZURE .........................................16 Step 1: Create or edit the VPG .................................................................................... 16 Step 2: Assign the Static IP Address ............................................................................ 16 Step 3: Failover Test the Virtual Machine ................................................................... 17 LINUX VERSIONS TESTED ......................................................................................................18 REFERENCES ..........................................................................................................................19 ENDNOTES ............................................................................................................................19 Linux Virutal Machine Configuration Guide for Azure 1 of 20 About this Guide Zerto enables migrations and disaster recovery (DR) capabilities between multiple clouds. For the most part, the experience is seamless to the virtual machines (VMs), and there is no impact on the VMs while moving between on-premises VMware or Hyper-V environments and Azure. Zerto can move any distribution or version of Linux to Azure. To see if the version you have is supported, check the Microsoft documentation. However, when many Linux VMs move to Azure, they may not have the right drivers and will not have network connectivity. Additionally, it is not unusual for older versions of Linux to still be in production, so you need to configure the servers to re-platform between the sites and have specific platform profiles. This guide is for Linux administrators who want to configure their Linux virtual machines to be able to move between Azure and VMware on-premises sites. End State Operations Goals DR and migrations using Zerto are effectively re-platforming the Linux virtual machines with any re- platform operation, the challenges are: 1. Adding the necessary drivers to work correctly on-premises and in Azure 2. Automatically detecting and automatically handle the different virtual machine hardware profiles of the underlying platform. 3. Assigning the proper IP Address(s) to the VM Linux Virutal Machine Configuration Guide for Azure 2 of 20 How to prepare a CentOS 6x or RedHat 6x-based Virtual Machines Assumptions The following steps assume an on-premises VMware Linux VM with Azure as the target. If you are only looking to use Azure as a Disaster Recovery platform, and plan to continue running your VM’s in VMware or HyperV, these steps simply prepare a VM to run in Azure. If that never happens, the modification will remain harmless while running on VMware. It is significantly easier to do this before a failover than it is after. On the production virtual machine, the one running in VMware that you are planning to failover or move to Azure, you will want to do the following steps. Step 1: Modify Grub Options These steps will enable a serial console so if something goes wrong you can leverage the Microsoft Serial Console for troubleshooting, you should NOT skip this step. Use VI or nano to edit /boot/grub/grub.conf Look for the line that starts with “kernel” under your default Kernel boot option, see screenshot below Usually the default kernel is the first entry. Look for the kernel line. Linux Virutal Machine Configuration Guide for Azure 3 of 20 Remove the following options: rhgb quiet crashkernel=auto These options told grub to use the graphical bootloader and to use verbose kernel output to the console. Microsoft says they are not used for public cloud VMs. Crashkernel consumes about 128MB of ram, it can be left according to Microsoft, but they recommend removing it to save RAM. Now add these options: rootdelay=300 console=ttyS0 console=tty0 earlyprintk=ttyS0 These options tell grub to wait for 300 seconds for the root volume and turns on both the local console and serial console for boot output messages. Save and exit your text editor. Step 2: Configure agetty serial console The configuration above will enable all of the kernel boot debug to go to the serial console. If you want an interactive login prompt to also be on the serial console after boot up, you need to do this step too. Use a text editor to create a file at /etc/init/ttyS0.conf Then paste in the following text: #This service maintains a agetty on ttyS0. stop on runlevel [S016] start on [23] respawn exec agetty -h -L -w /dev/ttyS0 115200 vt102 Step 3: Add HyperV drivers to the dracut config Using your favorite text editor, edit /etc/dracut.conf Paste the following line into the file. (Make sure to leave the spaces before and after the driver names) add_drivers+=" hv_vmbus hv_netvsc hv_storvsc nvme ena xen_blkfront xen_netfront mptbase mptscsih mptspi " Update the initramfs by running the following command. dracut --force -v Linux Virutal Machine Configuration Guide for Azure 4 of 20 If possible, it is a good idea to reboot the machine to make sure everything is working ok. Step 4: Check to see if Hyper-V modules are loaded If you are able to reboot the VM after running all the commands above, you should check to see if the Hyper-V modules have been loaded. lsinitrd | grep hv You should see something like the following: All three HyperV kernel modules are now loaded If those commands worked you should be ready for failover or migration. Perform a Zerto test failover into Azure just to confirm, and repeat the failover test after each kernel upgrade just to make sure all is still working well. Step 4: Add persistent rule for Azure Nics Next edit /etc/udev/rules.d/70-persistent-net.rules We want to add a new line that will map the network card using the HyperV driver to an unused “eth” name. I will use eth99, but you can use whatever you would like as long as its not already used. Add this line at the bottom of the file: SUBSYSTEM=="net", ACTION=="add", DRIVERS=="hv_netvsc", ATTR{type}=="1", KERNEL=="eth*", NAME="eth99" (If you are using nano, I recommend just copying the line that is already in this file for eth0, and then modifying it to look like the line above. Doing it that way will eliminate Copy/Paste errors of Windows text to Linux text.) What it should look like now (assuming you only had one rule to start): Mapping Azure nic to eth99 Linux Virutal Machine Configuration Guide for Azure 5 of 20 Now we can create an ifcfg-eth99 file and set it up for DHCP. NOTE: If you want to be able to automatically fail back from Azure, and have the VMware NIC reattach to your original eth0 configuration you need to also edit the top line. You need to remove the ‘ATTR(address)==”YOUR:MAC:ADDRESS”, ‘ This will allow non-Azure nics to be eth0. Step 5: Creating an ifcfg-eth file for the Azure NIC: Create a new file at /etc/sysconfig/network-scripts/ifcfg-eth99 Then add the following to the file: NAME="eth99" DEVICE="eth99" BOOTPROTO=dhcp ONBOOT=yes Make sure that the ” ” marks look like the file below. If they do not, manually type them. Sometimes Copy/Paste from a browser does funny things to text in Linux. It should look like this: eth99 config Note: If you want to automatically fail back from Azure and have the VMware NIC reattach to eth0, you will need to edit /etc/sysconfig/network-scripts/ifcfg-eth0 as well. Find the line that starts with “HWADDR=” and