Booting the Azure server cloud image on local Hyper-V Windows Hypervisor with optional Secure Boot enabled

Booting a pre-built Ubuntu cloud image in local Hyper-V Windows Hypervisor could save you the time of creating a blank .vhdx virtual disk and installing Ubuntu with an ISO. However, the process of booting a cloud-image on Hyper-V Windows Hypervisor has a couple of gotchas that are not entirely obvious, and a known bug in initramfs-tools that requires a workaround to enable a serial console for the VM (Step 6 below).

Here are steps for booting the Azure-customized Ubuntu 18.04 LTS (Bionic) server cloud image in Hyper-V. These steps assume you have access to a bare-metal machine running Windows with Hyper-V Windows hypervisor installed and enabled.

  1. Download an Ubuntu-for-Azure to your Windows machine from, in this case, the latest Bionic Release.

  2. Unzip the vhd

  3. Gen2 Hyper-V VMs require .vhdx disks, so you’ll need to convert the vhd to a vhdx. You can use the Convert-VHD powershell command or take the following steps:

    1. From the Hyper-V Management Application Action menu, select Edit Disk.
    2. Follow the wizard steps to convert the .vhd file to .vhdx disk format
  4. Create a new Generation 2 VM in Hyper-V Manager, using the Ubuntu .vhdx file as the VM disk

  5. Once the VM is created, select the VM and then select Settings

  6. Enable a serial console for the VM by entering the following command in a PowerShell prompt run as administrator (this is a workaround to a known bug with initramfs-tools in which boot stalls if a serial console is unavailable):

    Set-VMComPort -VMName <your VM name> -Number 1 "\\.\pipe\dbg"
  7. The Ubuntu Bionic Azure image is capable of optionally booting with Secure Boot, though this is not required. If you want to use this feature, enable the following Secure Boot settings:

    1. Enable Secure Boot checkbox
    2. Select Microsoft UEFI Certificate Authority from the dropdown menu
    3. Enable Trusted Platform Module checkbox
  8. Start the VM

1 Like