Blog About Hardware guide
7 February 2019

Ubuntu on Hyper-V

by Mathieu Poliquin

EDIT 2022:

If you mostly need the command line and want GPU support even in Windows 10/11 Home edition using the new WSL2 (windows Subsystem for Linux 2) is much easier. It also supports X11 graphical apps.

Screenshot of Ubuntu running on Hyper-V ubuntu vm

I often need to use both Windows and Linux for various projects. I was dual booting Linux and Windows 10 on my laptop but constantly rebooting was getting quickly annoying so recently I decided to try Hyper-V since it comes for free with my Windows 10 Pro.

Important notes so you don’t waste time:

Step 1 - Enable Hyper-V features in windows

In Control Panel find the Windows Features section and check out ‘Hyper-V’ windows feature

Step 2 - Open Hyper-V and Install Ubuntu Enhanced Mode

There is two ways to install Ubuntu:

I very strongly recommend the second option. It has the following features available throught xrdp pre-installed

If you must have a different version of Ubuntu such as 18.10 Cosmic Cuttlefish, it’s possible but you will need to install xrdp

Open the wizard with the menu:

Action->Quick Create

You should see this screen. Select Ubuntu 18.04 LTS and click create quick create

After the wizard finished downloading and creating your VM, you should see it in the list: hyper-v

Step 3 - VM Settings

Before starting up you need to change two things in the settings Right-click on your VM in the list and select “settings”

Disable secure boot, (otherwise it won’t boot) secure_boot

Specify RAM: Make sure to give it at least 4GB ram

Assign default switch for networking: net

Assign at least 2 to 4 processors hyper-v

To enable which local resources (drives, printers usb devices, etc) you want to expose to Ubuntu Microsoft made a neat doc for it: local resources

Step 5 - Configure Ubuntu

Update the linux kernel to one optimized for Azure VMs

In a terminal:

sudo apt-get update
sudo apt-get install linux-azure

Update and tweaks:

Besure to run the Auto-Updater to make sure you have the latest fixes and optimisations, especially the ones related to Azure

Best Pratices from Microsoft for Ubuntu on Hyper-V

GPU Support

Important Note These steps did not work for me as my laptop hardware doesn’t support this feature, that said I plan to try on other hardware, will update this post when I do

First make sure your hardware is compatible by running this script in a powershell as administrator: survey-dda.ps1 In case you want more about this script, you can read this detailed Microsoft blog post

Running this script you might get an error saying “Execution is disabled on this computer…” In which case you can bypass it by running the command as follows:

powershell -ExecutionPolicy ByPass -File survey-dda.ps1

As you can see my GTX 1060 5GB cannot be assigned, probably because I am running it on a x79 motherboard: compatibility

Microsoft recently disabled RemoteFX3D since they are developing a new solution to support GPUs. They only disabled it in the interface (for now), you can enable it via Powershell

Add-VMRemoteFx3dVideoAdapter -VMName YOUR_VM_NAME

Reference: NVIDIA docs

Step 1 - Get the PCI location of your GPU and disable it

Using the device manager, Open the properties of your graphics card. In the details pane acces Location Paths property and copy it’s value gpu location

Disable you GPU from your computer so you can assign it fully to your VM. Right-click on your graphics card in the Device Managet and select Disable

Dismount your graphics card from the host and assign it to your VM Open a powershell as admin and use these commands. Replace the LocationPath and VMName with yours

Dismount-VMHostAssignableDevice -LocationPath "PCIROOT(0)#PCI(1C00)#PCI(0000)" -force
Add-VMAssignableDevice -LocationPath "PCIROOT(0)#PCI(1C00)#PCI(0000)" -VMName Ubuntu

To verify it’s assigned list the assignable devices for your Ubuntu

Get-VMAssignableDevice -VMName Ubuntu

In case you don’t want to use the gpu on yourVM anymore you can use these commands to give it back to your host

Remove-VMAssignableDevice -LocationPath "PCIROOT(0)#PCI(1C00)#PCI(0000)" -VMName Ubuntu
Mount-VMHostAssignableDevice -LocationPath "PCIROOT(0)#PCI(1C00)#PCI(0000)"

After go in Device Manager and Enable your Graphics card

Step 2 - Install vGPU in Ubuntu

NVIDIA provided a section for that: VGPU on Ubuntu


Performance is of course not as snappy as on native hardware, the mouse lags a little and you can see the windows refresh. Until they improve the performance you will definetly find that it’s annoying to do long hours of programming or other involved work on this, for which I recommend dual booting instead if that is your case. As for me, I have another computer with Ubuntu set up when I need to do heavier work. Otherwise for tweaking and testing scripts Hyper-V Ubuntu VM is fine.

I would recommend having a processor with a decent single-core performance. My Xiaomi Notebook pro have a Intel Core i7-8550U with a single-core performance of over 170 on Cinebench! It peforms better than my Dual Xeon E5-2680v2 which has a 95 single-core Cinebench score, even thought the multi-core performance is 5 times higher!

Performance Test with the VM running on my Xiaomi notebook pro 2017:

python3 -m --alg=ppo2 --env=PongNoFrameskip-v4 --num_timesteps=2e7


Hardware specs:

tags: ubuntu - hyper-v - linux - gpu - windows