Tuesday, November 11, 2025

Hyper-V "Enhanced session" with Ubuntu 24.04

The VirtualBox performance has been quite bad since Windows 11 comes with Hyper-V enabled. It is a mess to try to disable Hyper-V on Windows 11. The VMWare Workstation Pro is an alternative but the future of it is unclear with Broadcom in charge.

So Hyper-V seems to be a good solution. But it is focused on server use and not desktop use. One of the main drawbacks is not being able to copy/paste between the VM and the Host. Luckily this is possible with the "Enhanced session" support of Hyper-V but it was not quite straightforward to accomplish using xrdp. Even when working, a drawback was not being able to adjust the resolution and zoom.

There are other options such as VNC etc. but XRDP is probably the best performing option for general use. So below are the steps to setup XRDP on Ubuntu 24.04 to use with Hyper-V

Step 1:

Install Ubuntu 24.04 Server. I wanted to start with a very clean installation. Because apparently Wayland can cause some problems. So it is better to avoid Ubuntu Desktop installation which uses Wayland.

Make sure to set it to use HvSocket otherwise enhance session won't be available

Set-VM -Name "<VM_NAME>" -EnhancedSessionTransportType HvSocket

Step 2:

Install XFCE and XRDP

  $ sudo apt install xfce4 xrdp

Step 3:

Edit `lightdm.conf` to include following. If you already tried to login before setting this, you might have created a file in /var/lib/AccountService/users/USERNAME Just delete it. 

[SeatDefaults]
user-session=xfce

Edit /etc/xrdp/xrdp.ini to include following: 

port=vsock://-1:3389
use_vsock=true
security_layer=rdp

The security_layer=rdp is simply to avoid trying to use encryption for a local connection which doesn't work if you do not setup certificates anyway.

Step 4:

Edit ~username/.xsession and make it executable (755). The first line is for scaling everything 2x.

export GDK_SCALE=2
startxfce4