In order to install Ubuntu as a Generation 2 Hyper-V virtual machine, you have to switch the Secure Boot Template to Microsoft UEFI Certificate Authority as follows.

Ubuntu guest operating system support
Generation 2 is supported for:
Ubuntu 20.04
Ubuntu 18.04
Ubuntu 16.04
Ubuntu 14.04

Source: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/plan/should-i-create-a-generation-1-or-2-virtual-machine-in-hyper-v#ubuntu-guest-operating-system-support


What are the advantages of using generation 2 virtual machines?
– Secure Boot
– Larger boot volume

Source: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/plan/should-i-create-a-generation-1-or-2-virtual-machine-in-hyper-v#what-are-the-advantages-of-using-generation-2-virtual-machines


Security -> Enable Secure Boot -> Microsoft UEFI Certificate Authority


The templates described in the following table refer to the certificates that you need to verify the integrity of the boot process.

Template nameDescription
Microsoft WindowsSelect to secure boot the virtual machine for a Windows operating system.
Microsoft UEFI Certificate AuthoritySelect to secure boot the virtual machine for a Linux distribution operating system.
Open Source Shielded VMThis template is leveraged to secure boot for Linux-based shielded VMs.

For more information, see the following topics.

Source: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/learn-more/generation-2-virtual-machine-security-settings-for-hyper-v


To optimize the virtual machine for Microsoft Hyper-V install also the linux-azure package.

# apt-get update
# apt get-install linux-azure
# reboot

This will install the Azure Kernel in Ubuntu.


You can also check if the kernel finally changed

uname -a
Linux ubuntu 5.11.0-1021-azure #22~20.04.1-Ubuntu SMP Fri Oct 29 01:11:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Azure Tailored Linux Kernel in Ubuntu
https://lnx.azurewebsites.net/azure-tailored-linux-kernel-in-ubuntu/

Canonical (the company behind Ubuntu Linux distribution) with the team at Microsoft Azure announced in September last year, that Ubuntu Cloud Images for Ubuntu 16.04 LTS on Azure have been enabled with a new Azure tailored Ubuntu kernel by default.

The kernel itself is provided by the linux-azure kernel package. The most notable highlights for this kernel include:

– The very latest Hyper-V device drivers and feature support available.
Hyper-V socket capability — a socket-based host/guest communication method that does not require a network.
– NAPI and Receive Segment Coalescing for 10% greater throughput on guests not using SR-IOV.





Links

Generation 2 virtual machine security settings for Hyper-V
https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/learn-more/generation-2-virtual-machine-security-settings-for-hyper-v

Azure Tailored Linux Kernel in Ubuntu
https://lnx.azurewebsites.net/azure-tailored-linux-kernel-in-ubuntu/