How to Install Ubuntu in a Hyper-V Generation 2 Virtual Machine
If you want to install Ubuntu or any other Linux inside a Hyper-V Generation 2 Virtual Machine you need to do a simple change to the VM so you can install it from ISO. If you create a Hyper-V Generation 2 Virtual Machine and try to start the Virtual Machine, the Virtual Machine will not boot from ISO. This is because of the Secure Boot feature, which is included in Hyper-V Generation 2 Virtual Machines and applies to all Linux operating systems running on Hyper-V.
If you don’t want to install the Ubuntu manually, you can simply use the Ubuntu images from the Hyper-V Quick Create gallery. This has all the necessary tools already installed.
How to Install Linux in a Hyper-V Generation 2 VM
Create a new Virtual Machine in the Hyper-V Manager
On the Hyper-V Virtual Machine Generation selection screen, choose Generation 2
Attach the Ubuntu ISO Image to the virtual machine
After you have created the Virtual Machine using the wizard, go into the settings of the virtual machine. Switch to the Security section and choose the Microsoft UEFI Certificate Authority Secure Boot Template.
Now the Virtual Machine will boot from the Ubuntu ISO, and you can install Ubuntu.
On long-term support (LTS) releases use the latest virtual Hardware Enablement (HWE) kernel for up-to-date Linux Integration Services. To install the Azure-tuned kernel on 16.04, 18.04, and 20.04, run the following commands as root (or sudo):
apt-get update apt-get install linux-azure
I hope this helps, if you have any questions feel free to leave a comment below.