Ubuntu 20.04 LTS Hyper-V

Installation of Linux Ubuntu 20.04 LTS in a Hyper-V Version 2 Virtual Machine with a UEFI BIOS, Secure Boot and Machine Owner Key (MOK)

In this guide I will go through the installation of Ubuntu 20.04 LTS in a Hyper-V Virtual Machine on a Windows 11 Pro Host PC using optimal Virtual Machine settings for both performance and security. To instead install Ubuntu 20.04 LTS directly on your Dell PC see my other guide:

Hyper-V is an optional Windows feature only available in Windows 11 Pro/Education and is not available for Windows 11 Home (for windows 11 Home and Non-Commercial use, you can use VMware instead). Hyper-V can be used to create a more Secure VM with a UEFI BIOS and Secure Boot and a Machine Owner Key (MOK). Typically the Hyper-V VM has superior performance to the VM produced by VMware. Hyper-V is also cheaper to run for Commercial use as Business systems tend to have Windows 11 Pro preinstalled and the cost for Hyper-V on the other hand is incorporated into the Windows 11 Pro OEM License included with the PC. VMware has the edge over Hyper-V when it comes to usability as it automatically updates the VMs display using VMware Tools in response to the VM Window being resized on the Host PC. We can however make our VM full screen with a few additional command lines.

The minimum system requirements for Hyper-V are roughly inline with the minimum system requirements for Windows 11 Pro i.e. a computer with a 6th Generation Intel Processor or AMD Equivalent or later. To run a VM the Windows 11 Pro Host PC should have at least 8 GB of RAM installed. A minimum of 4-6 GB of the RAM should be reserved for the Host PC otherwise there will be a performance lockup. This allows the VM to have 2 GB of RAM. If your Windows 11 Pro Host PC has 16 GB of RAM or higher, you can safely allow the VM to use 4 GB of RAM. The OS Boot Drive on the Windows 11 Pro Host PC should be at least a 250 GB SSD. Note a mechanical HDD will lock up to 100 % Disk Usage when used to run Windows 11 Pro and a VM on top giving a bottleneck in terms of system performance.

Video

Enable Hyper-V

To enable Hyper-V on your Windows 11 Pro PC. Right click the Start Button and select Windows Terminal (Admin):

Windows 11 Power User Menu.

Then Accept the User Account Control Prompt:

Windows 11 User Account Control.

Then type in the following command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Enable Hyper-V using PowerShell in Windows 11 Terminal.

This will download the latest version of Hyper-V from Microsoft servers. To install this Windows feature you will need to input to restart when prompted. Input:

y
Windows Terminal restart your computer prompt.

The PC will restart and configure Hyper-V.

Hyper-V installation.

Hyper-V can be found in the Windows 11 Start Menu under windows Tools:

Hyper-V on Windows 11 Start Menu.

Download Ubuntu ISO

You will next need a Ubuntu 20.04 LTS ISO.

The ISO should have Update 1 or Higher as the original Ubuntu 20.04 ISO has an outdated GRUB2 Bootloader which is not compliant with mid 2020 or newer Secure Boot. Secure Boot was updated in mid 2020 in response to a Security Exploit found in old GRUB2 Bootloaders.

Configure a VM: New VM Wizard Setup

Launch Hyper-V Manager:

Launch Hyper-V.

To the left hand side you will see your computers name:

Hyper-V Manager. Your Computer Name.

Right click your Computer Name and select New → Virtual Machine:

Create a new Hyper-V Virtual Machine.

Select Next:

Hyper V New Virtual Machine Wizard.

Name your VM e.g. Ubuntu 20.04 LTS and then select Next:

Hyper V New Virtual Machine Wizard, VM Name.

For best performance and Security select Generation 2 which will create a VM with a Virtual UEFI BIOS. Generation 1 is a VM with a Legacy BIOS which is obsolete:

Hyper V New Virtual Machine Wizard, Virtual Machine Generation 2 UEFI BIOS and Secure Boot.

Open the Task Manager pressing [Ctrl], [Shift] + [Esc] and have a look at your memory. In my case there is 16 GB installed with Windows using ~4 GB and 11.8 GB of RAM available. It is safe for me to assign the VM 4 GB of RAM. If you have 8 GB of RAM you may be better to give the vM 2 GB:

Windows 11 Task Manager Memory.

Update the Startup Memory to 4096 MB or 2048 MB if your PC only has 8 GB of RAM. Select Next:

Hyper V New Virtual Machine Wizard, assign Startup Memory.

Change the Network to Default Switch. This will give you a Virtual Ethernet based upon your Host PCs Internet Connectivity. Select Next:

Hyper V New Virtual Machine Wizard Configure Network using the Default Switch.

Use the default settings to Create a Virtual Hard Disk. The maximum size by default is 127 GB which is ample in most cases. Note that it is a dynamically expanding Virtual Drive so won't actually occupy the maximum fill size (unless you fill it to the brim with data). If you have a 2 TB SSD you can optionally make the maximum size larger if desired. Select Next:

Hyper V New Virtual Machine Wizard, create a Dynamic Virtual Hard Disk.

Under Installation Options select Install an Operating System from a Bootable Image File and then select Browse:

Hyper V New Virtual Machine Wizard, load the Ubuntu 20.04 ISO.

Select your Ubuntu 20.04 ISO:

Hyper V New Virtual Machine Wizard. Select the Ubuntu 20.04 LTS ISO.

Select Next:

Hyper V New Virtual Machine Wizard. Select Next.

Select Finish:

Hyper V New Virtual Machine Wizard Finish.

Configure a VM: VM Settings

The VM will be created however it is optimised for a Windows install and not a Ubuntu install,

Hyper-V Ubuntu 20.04 LTS Virtual Machine.

We need to right click the VM and select Settings to access additional settings not displayed in the New Virtual Machine Wizard:

Ubuntu 20.04 LTS Hyper-V Virtual Machine Settings.

Under Security, Secure Boot should be checked by default. We need to Change the Template from Microsoft Windows (which will only allow Windows to Boot) to Microsoft UEFI Certificate Authority (which will allow Linux Distros with a Secure Boot Signature to Boot). Under Encryption Support Enable Trusted Platform Module and then select Apply:

Hyper-V Virtual Machine Security Settings. Enable Secure Boot using a Microsoft UEFI Certificate Authority and Enable the Trusted Platform Module.

Press [Ctrl}, [Shift] and [Esc] to open the Task Manager and have a look at your CPU. You are interested in the number of Cores. If your CPU has 4 Cores, update the Number of Virtual Processors to 2. If it has 8 Cores update the Number of Virtual Processors to 4:

Windows 11 Task Manager. CPU Cores.

In this case I will update the number of Virtual Processors to 2 and then select Apply:

Hyper-V Assign the number of Virtual Processor Cores.

Select Integration Services and check Guest Services then select Apply:

Hyper-V Virtual Machine Integration Services Settings. Enable Guest Services.

Connecting and Starting the VM

Right click the VM and select Connect (selecting tart Directly will launch the VM without Displaying the VM output to the user):

Connecting to a Hyper-V Virtual Machine.

Then select Action and Start:

Starting a Hyper-V Virtual Machine.

Installing Ubuntu from the Ubuntu Live ISO Image

The VM will automatically boot to the Ubuntu ISO Image. Ubuntu should be selected press [Enter]:

Ubuntu 20.04 Live ISO Boot Menu.

You will see the Hyper-V logo and it will check the installation media integrity:

Hyper-V Virtual UEFI BIOS splash screen.
Ubuntu ISO File Integrity Check.

You will be informed the installation media is okay:

Ubuntu ISO File Integrity Check Complete.

You will now see the Hyper-V and Ubuntu logo with spinner as the Ubuntu Live ISO Starts:

Ubuntu Hyper-V Loading Screen with Spinner.

To the left hand side select your language and then select Install Ubuntu:

Ubuntu Setup: Select Language and Install Ubuntu.

Select your Keyboard Layout and then select Next:

Ubuntu Setup: Select Keyboard Layout.

Normal installation should be selected by default. As you are already connected to the internet, Download Updates while Installing Ubuntu will automatically be checked. Check Install Third-Party Software for Graphics and Wi-Fi Hardware and Additional Media Formats. Then create a Machine Owner Key and confirm the Machine Owner Key. We will need to provide the Machine Owner Key to the Hyper-V UEFI BIOS during the first time Boot to authorise the Boot with the additional drivers and multi-media audio codecs. Select Next:

Ubuntu Updates and Other Software. Normal Installation with Updates, third party drivers, multimedia codecs and a Machine Owner Key to Configure Secure Boot.

Select Erase Disk and Install Ubuntu then select Next:

Ubuntu Setup: Erase Disk and install Ubuntu.

Select Continue:

Ubuntu Setup: Erase Disk and install Ubuntu Confirmation.

Select your Capital City/Timezone on the map or dropdown list and select Next:

Ubuntu Setup: Location and Timezone, map and dropdown list.

Input your Name (Full Name) and Usernmae (lower case only with no special characters). The computer name will be generated from your username and PC model (in this case Virtual-Machine). Input your password and confirm it. Then select Continue:

Ubuntu Setup: User Account Setup.

Select Restart Now:

Ubuntu Install Restart Prompt.

First Time Boot (MOK Enrollment)

The Ubuntu first time boot will be blocked by the UEFI BIOS because it includes the third-party drivers and multimedia codecs. The UEFI BIOS will recognise that the boot has a new Machine Owner Key and take you to the MOK Management screen. Press [↓] and highlight Enroll MOK, then press [Enter]:

Ubuntu First Time Boot MOK Management. Enroll MOK.

Then press [↓] and highlight [Continue] and press [Enter]:

Ubuntu First Time Boot MOK Management. Continue.

Then press [↓] and highlight Yes and press [Enter]:

Ubuntu First Time Boot MOK Management. Yes.

Input your MOK and press [Enter]. Note no characters display when you are inputting text:

Ubuntu First Time Boot MOK Management. Input MOK.

If the key matches it will be accepted and you will be prompted to Reboot. Press [Enter]:

Ubuntu First Time Boot MOK Management. Reboot.

Now Ubuntu will Boot with the multimedia codecs and additional drivers past Secure Boot. You will see the Hyper-V OEM logo and Ubuntu logo splash screen with the Ubuntu spinner:

Ubuntu First Time Boot Hyper-V OEM logo and Ubuntu spinner.

Select your User Name:

Ubuntu login screen.

Input your password to login:

Ubuntu input your password.

You will now be prompted to connect to Online Accounts. I am going to skip this:

Ubuntu welcome setup screen, connect to your online accounts.

You will be informed about Livepatch. I am going to select Next:

Ubuntu welcome setup screen, live patch.

You can optionally turn on Location Services (useful if you plan to use things like maps). Once you have made your selection, select Next:

Ubuntu welcome setup screen, location service settings. Turn on if you are going to use things like maps.

You can optionally send system info to Canonical (the company who develop Ubuntu). Once you have made your option select Next:

Ubuntu welcome setup screen, send system information to help improve Ubuntu.

You will be informed about the Software Store. Select Done:

Ubuntu welcome setup screen, Software (Store).

Updating Ubuntu

You should now update Ubuntu. Go to the Start Screen and select Software Update (don't confuse this with Software and Update Settings to the left hand side of it that has a very similar name and icon):

Ubuntu Start Menu and Software Updater.

Select Install Now:

Ubuntu Software Updater. Install Updates.

To install updates, elevated permissions are required and you will get an Authentication Prompt, the Linux equivalent of Windows User Account Control. In the case of Linux, you need to input your password and then you can select Authenticate:

Ubuntu Authentication Prompt.

Once the updates are installed, select Restart Now. The VM will reboot and you will be prompted to login again:

Ubuntu Software Updater Restart Prompt.

Making the VM Full Screen

If we right click the Ubuntu Desktop in the VM and have a look at Display Settings. We will see the resolution is very small:

Ubuntu Display Hyper-V VM Resolution.

If we do the same on the Windows 11 Desktop we can see the resolution of our monitor:

Windows 11 Display Settings.

In my case it is 1920×1080. Note the Hyper-V VM has no Aerosnap option and no snap layouts when the maximise button is selected. The VMs graphic display is behind that of VMwares. In the case of VMware Ubuntu has inbuilt VMware tools and the Window can be snapped to any size on the Host PC and the display of the VM will automatically update in accordance to the Window size.

Hyper-V lack of support for Windows 11 snap.

When we maximise the Hyper-V VM it stays the same size:

Ubuntu Hyper-V VM not taking up full screen when maximised.

To make the Virtual Machine full screen we are going to modify the display settings of the GRand Unified Bootloader GRUB of the VM using the Terminal.

Go to the Start Screen and open up the Terminal (the shortcut key [Ctrl], [Alt] and [ t ] will also open up the Terminal):

Ubuntu Start Menu, launch Terminal.

Type in the following command:

sudo nano /etc/default/grub
Ubuntu edit the grub using the terminal and nano.

sudo is an abbreviation for super user do. This means we want to run the command with administrator privileges. To do so we will be prompted for our password:

Ubuntu command line authentication prompt.

nano is the name of a text editor and /etc/default/grub is the name of the file we wish to edit in nano.

Ubuntu quiet splash default setting.

Press the arrow keys to highlight the line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

We want to update the end of the line to:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"

Note 1920×1080 is the screen resolution of my Windows 11 Pro Monitor. You can check your screen resolution by right clicking the Windows Desktop and selecting display. For convenience the code uses the letter x and not the multiply symbol ×.

Once the line is modified press [Ctrl] + [x] to exit:

Ubuntu video=hyperv_fb:1920x1080 video setting.

Then [y] to save:

Ubuntu nano save prompt.

The next screen will display the file name. We want to overwrite the file so just press [Enter] to overwrite the original file:

Ubuntu nano file location save dialog.

This should exit the text editor nano and return you to the terminal.

To update the grub bootloader type in:

sudo update-grub
Ubuntu update grub using the terminal.

Then to reboot type in:

sudo reboot
Reboot using the terminal.

The VM should start full screen (maximise it to display it full screen on your Host PC):

Hyper-V Ubuntu VM now full size.
Ubuntu installed in Hyper-V VM and maximised to full size.

You should now be able to use Ubuntu as a Full Screen VM with the security settings expected for a modern computer and decent performance.