Running Ubuntu in Hyper-V is a clean way to get a Linux box on a Windows machine without dual-booting or buying hardware. Modern Ubuntu boots happily as a Generation 2 VM, the integration drivers ship in the kernel, and once Enhanced Session Mode is set up you get a resizable desktop with a shared clipboard.
There’s one gotcha that catches almost everyone, and it’s worth stating up front: Hyper-V’s default Secure Boot template is built for Windows and won’t trust Ubuntu’s bootloader. Leave it on the default and your VM won’t boot. Switch it to the Microsoft UEFI Certificate Authority template and Ubuntu starts fine with Secure Boot still on.
This walks through building the VM correctly, getting past that Secure Boot issue, finishing the install, and fixing the cramped default resolution so the desktop is actually usable.
Before you start
What you need
- Hyper-V enabled on Windows 11 Pro/Enterprise or Windows Server
- An Ubuntu ISO (LTS release recommended for stability)
- A virtual switch for network access (the Default Switch works for NAT/internet)
- About 4 GB RAM and 25 GB+ disk free for a desktop install
- Enough host CPU/RAM to spare 2 vCPUs and the VM's memory
If Hyper-V isn’t enabled yet, that’s a quick job on its own — see installing Hyper-V on Windows 11 Pro. And if you’re not sure whether to build Generation 1 or 2, the short answer below is Generation 2, but Generation 1 vs Generation 2 covers the full reasoning.
Step 1: Create a Generation 2 VM
In Hyper-V Manager, choose Action → New → Virtual Machine and walk the wizard:
- Name the VM (e.g.
Ubuntu-LTS). - Generation: choose Generation 2. This is the important one — UEFI firmware, faster boot, better device support. Generation can’t be changed after creation, so get it right now.
- Memory: 4096 MB for a desktop. Leave Dynamic Memory ticked so it only uses what it needs.
- Networking: connect to Default Switch for instant NAT-based internet, or an external switch if the VM should appear on your LAN.
- Disk: create a new VHDX, 25 GB or more. It’s dynamically expanding by default, so it grows as you use it.
- Installation: point it at your Ubuntu ISO.
Prefer PowerShell? This creates the same VM in one block:
New-VM -Name "Ubuntu-LTS" -MemoryStartupBytes 4GB -Generation 2 `
-NewVHDPath "D:\VMs\Ubuntu-LTS.vhdx" -NewVHDSizeBytes 40GB `
-SwitchName "Default Switch"
Add-VMDvdDrive -VMName "Ubuntu-LTS" -Path "D:\ISOs\ubuntu.iso"
Step 2: Fix Secure Boot before you start the VM
This is the step that saves you a frustrating “no bootable device” or boot failure. With the VM created but not started, open its Settings → Security.
You’ll see Secure Boot enabled with the template set to Microsoft Windows. That template only trusts Windows boot components, so Ubuntu’s signed bootloader (shim) is rejected. Change the template:
- Set Template to Microsoft UEFI Certificate Authority.
That template includes the certificate Ubuntu’s bootloader is signed against, so the VM boots with Secure Boot still enabled. Don’t disable Secure Boot unless you have a reason to — switching the template is the correct fix.
In PowerShell, the same change is one command:
Set-VMFirmware -VMName "Ubuntu-LTS" -SecureBootTemplate "MicrosoftUEFICertificateAuthority"
To confirm the boot order points at the DVD first for installation:
Set-VMFirmware -VMName "Ubuntu-LTS" -FirstBootDevice (Get-VMDvdDrive -VMName "Ubuntu-LTS")
Step 3: Set the VM resources
While you’re in Settings, give the VM what it needs for a smooth install:
Recommended Ubuntu VM settings
| Generation | 2 (UEFI) |
|---|---|
| Secure Boot template | Microsoft UEFI Certificate Authority |
| Startup RAM | 4096 MB (desktop) / 2048 MB (server) |
| Dynamic Memory | Enabled, with a sensible minimum and maximum |
| Virtual processors | 2 or more |
| Disk (VHDX) | Dynamically expanding, 25–40 GB |
| Network | Default Switch (NAT) or an external switch |
Two vCPUs make the installer and desktop noticeably more responsive than one. Dynamic Memory means the VM gives RAM back to the host when idle, which is handy when you’re running other things alongside it.
Step 4: Install Ubuntu
Start the VM and connect to it. The Ubuntu installer loads from the ISO. From here it’s the standard Ubuntu flow:
- Choose Try or Install Ubuntu.
- Pick your language and keyboard.
- Select a normal or minimal installation and choose whether to download updates during install.
- For disk setup, Erase disk and install Ubuntu is correct here — it only touches the VHDX, not your host.
- Set your region, create a user account, and let it install.
- When prompted, reboot. Remove the ISO so it boots from disk:
Set-VMDvdDrive -VMName "Ubuntu-LTS" -Path $null
Because modern Ubuntu kernels include the Hyper-V integration drivers, networking, storage, and basic mouse/keyboard integration work immediately after install. There’s no separate integration package to chase down the way there was on older Linux guests.
Step 5: Fix the resolution with Enhanced Session Mode
Out of the box, an Ubuntu VM often runs at a small fixed resolution and won’t resize when you stretch the window. The fix is Enhanced Session Mode, which connects over RDP via the VMBus for a resizable desktop, shared clipboard, and better display scaling. It’s automatic for Windows guests; Ubuntu needs setup inside the guest.
The common approach uses xrdp and the Hyper-V tooling. Microsoft provides a setup script, and Ubuntu’s linux-vm-tools route configures xrdp for Enhanced Session. In broad strokes, inside the Ubuntu VM you:
- Install and configure xrdp plus the Hyper-V Enhanced Session components.
- Shut the VM down.
- On the host, set the VM to use Enhanced Session over the HV socket transport:
Set-VM -VMName "Ubuntu-LTS" -EnhancedSessionTransportType HvSocket
- Start the VM and reconnect. You’ll get a resolution prompt and a resizable desktop.
If you’d rather skip xrdp and just stop the desktop from being tiny, you can hard-set a resolution in GRUB. Edit /etc/default/grub, set a video mode on the kernel line, then update GRUB:
# In /etc/default/grub, add to GRUB_CMDLINE_LINUX_DEFAULT, e.g.:
# video=hyperv_fb:1920x1080
sudo update-grub
sudo reboot
Step 6: Snapshot the clean install
Once Ubuntu is installed, updated, and the display is sorted, take a checkpoint in Hyper-V Manager (right-click the VM → Checkpoint). If you later break something experimenting, you can roll back in seconds.
Checkpoint-VM -Name "Ubuntu-LTS" -SnapshotName "Clean install + updates"
A checkpoint is a convenience for quick rollback, not a backup of anything you can’t lose — the same caution that applies to any hypervisor’s snapshots. Keep the checkpoint chain short, since a long stack of differencing disks gets messy over time.
Wrapping up
Ubuntu runs well in Hyper-V once you get two things right: build it as Generation 2, and switch the Secure Boot template to Microsoft UEFI Certificate Authority before first boot. Miss that template change and the VM won’t start; make it and Ubuntu boots with Secure Boot fully on.
After that it’s a normal Ubuntu install. The integration drivers come with the kernel, so networking and storage just work, and Enhanced Session Mode turns the cramped default window into a proper resizable desktop with a shared clipboard. Snapshot the clean state, and you’ve got a Linux lab you can rebuild whenever you want. For more Hyper-V and Linux walkthroughs, browse the virtualization guides.