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.
Unzip the vhd
Gen2 Hyper-V VMs require .vhdx disks, so you’ll need to convert the vhd to a vhdx. You can use the
Convert-VHDpowershell command or take the following steps:
- From the Hyper-V Management Application Action menu, select Edit Disk.
- Follow the wizard steps to convert the .vhd file to .vhdx disk format
Create a new Generation 2 VM in Hyper-V Manager, using the Ubuntu .vhdx file as the VM disk
Once the VM is created, select the VM and then select Settings
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"
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:
- Enable Secure Boot checkbox
- Select Microsoft UEFI Certificate Authority from the dropdown menu
- Enable Trusted Platform Module checkbox
Start the VM