Ubuntu 16.04 Azure Tips

Migrating Ubuntu to Azure

Ubuntu 16.04 LTS

The goal of this page is to get an Ubuntu 16.04 VM prepared for DR or migration into Azure (or AWS).

Ubuntu does have one advantage over CentOS and RHEL, in that the drivers for both Azure and AWS are already baked into the Ubuntu Kernel. So we can skip all the steps needed to add drivers to the initram file system. Let’s talk about what problems you will face.

It was hard to programmatically (and reliably) set network configurations for adapters that are not always in a system. However, with Netplan (introduced in Ubuntu 17.10), it gets a lot easier to do. Aside from installing and configuring Netplan my only other recommendation is to enable serial console output for visibility and ease of future troubleshooting.

Installing Netplan on Ubutu 16.04

Luckily, the Ubuntu team was good enough to backport netplan to 16.04. This means that we can install it from a simple apt-get command.

sudo apt-get update
sudo apt-get install nplan -y

Now that netplan is installed we need to provide YAML configuration files for the various network adapters that we want to use in the future. I have created YAML files for VMware, Azure, and AWS. You can download them from github here. The easier thing to do though is to clone the repo to your machine. You can then copy the YAML files to the /etc/netplan directory.

cd ~/
git clone https://github.com/recklessop/netplancfg.git
cp netplancfg/ubuntu/*.yaml /etc/netplan/

Now verify that the files are in your netplan directory.

cd /etc/netplan/
ls

You should see the following:

netplan config files in place

The only config file that needs to be modified is the VMware specific config. All of the other files are good to go out of the box, the 50-vmware-static.yaml file needs to be edited with your static IP information.

sudo nano 50-vmware-static.yaml

Inside of nano edit the address line, as well as the gateway, nameservers, search domain and macaddress. Pro Tip – ONLY USE SPACES, DO NOT USE TABS.

Make sure to edit the VMware config

Once you have your configuration adjusted save the file (Ctrl + O) then exit nano (Ctrl + x). Now we can run netplan generate to make sure that all is well with our config files.

sudo netplan generate

If there are no errors generated, check the /run/systemd/network/ folder and see if the configuration files have been generated.

cd /run/systemd/network/
ls

You should see this:

generated netplan configration files

This completes the work we need to do in order for the VM to get an address from Azure or AWS. Next we will work on enabling the serial console.

Enabling Serial Console on Ubuntu 16.04

This part is pretty easy, all we need to do is modify the default grub parameters and then update grub.

To edit the default grub file run the following command:

sudo nano /etc/default/grub

Once nano starts look for the line that starts with GRUB_CMDLINE_LINUX_DEFAULT

You will want to add the following text inside of the quote marks.

console=tty1 console=ttyS0 earlyprintk=ttyS0 rootdelay=300

The file should look like this when you are finished.

Click to view the full size image.

Save and Exit nano (Ctrl + O then Ctrl + x).

Now update grub with the following command

sudo update-grub

You should see it rebuild the grub configuration. When it is complete, reboot your VM if possible to verify that everything works locally.

Next try a test failover into Azure or AWS to verify that connectivity works there as well.

If you failover into Azure and check the Boot diagnostics tile, you should see kernel output like this:

Azure Serial Console output

Feedback

Let me know if you have any feedback.

Loading

2 Responses to "Ubuntu 16.04 Azure Tips"

  1. Hi Justin, thanks for the useful article!

    I’m currently hosting Ubuntu 16.04 on Vultr, but would like to get things setup to where a backup of it could be restored to Azure, AWS, etc.

    Would there be any possible negative side effects to installing Netplan on my live site? Could it somehow result in the network adapter there failing?

    Same with updating grub to work with serial console. Could it somehow cause the existing web-based console on my current host to stop working?

    I’m just not sure how to get things installed and setup without applying it on the working (Internet connected) VM, but still want to mitigate the risk of possible.

  2. It’s hard to say if changing things would affect the current setup because I don’t know what config the current setup has. It is possible though if the web-based console uses Serial instead of some sort of console graphics. I’m also not familiar with Vultr… so I’d hate to lead you down the wrong path.

Post Comment