https://github.com/arelius-d/ubuntu-24.04-hyperv-enhanced-session
Automated, idempotent setup script for Ubuntu 24.04 Hyper-V Enhanced Session. Bypasses the Xorg crash by enforcing TigerVNC and repairs PAM keyring login loops.
https://github.com/arelius-d/ubuntu-24.04-hyperv-enhanced-session
hyper-v hyper-v-ubuntu-install linux-vm tigervnc ubuntu-24-04 virtualization vm xrdp
Last synced: 2 months ago
JSON representation
Automated, idempotent setup script for Ubuntu 24.04 Hyper-V Enhanced Session. Bypasses the Xorg crash by enforcing TigerVNC and repairs PAM keyring login loops.
- Host: GitHub
- URL: https://github.com/arelius-d/ubuntu-24.04-hyperv-enhanced-session
- Owner: Arelius-D
- License: mit
- Created: 2026-02-19T22:32:41.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-02-19T23:31:10.000Z (3 months ago)
- Last Synced: 2026-02-20T02:57:20.449Z (3 months ago)
- Topics: hyper-v, hyper-v-ubuntu-install, linux-vm, tigervnc, ubuntu-24-04, virtualization, vm, xrdp
- Language: Shell
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ubuntu 24.04 Hyper-V Enhanced Session Setup
An automated, idempotent script to get Hyper-V Enhanced Session (XRDP) working on Ubuntu 24.04.
## The Problem
Setting up Enhanced Session on Ubuntu 24.04 is currently broken out-of-the-box using older methods. Recent Ubuntu updates introduced a performance regression with the default Xorg backend over XRDP, leading to hours upon hours of troubleshooting because the methods out there just aren't covering everything. There is way too much guesswork and they are prone to several errors along the way. I took it upon myself to find a workable solution for the latest `Ubuntu Desktop 24.04.4 LTS` release.
## The Solution
This script automates the necessary workarounds. It abandons the broken Xorg backend entirely and forces the system to use TigerVNC (`tigervnc-standalone-server`). It also injects the correct PAM configuration to allow the GNOME keyring to unlock properly.
### Key Script Features
* **Idempotent Execution:** The script checks if configurations are already applied before modifying files. It is safe to re-run if you think something broke.
* **Active Session Guardrail:** If you accidentally run this script while actively connected via an Enhanced Session, it will detect the `xrdp-chansrv` process and abort. Restarting XRDP while inside it causes a "zombie" session lock, so the script prevents you from nuking your own desktop.
* **Dynamic Resolution & Ultrawide Support:** Because the display transport is properly negotiated, you can use the Hyper-V slider to scale the VM to your monitor's exact native resolution.
## Prerequisites
1. A **Generation 2** Hyper-V Virtual Machine.
2. In the VM Settings under **Security**, you MUST check **Enable Secure Boot** and change the Template to **Microsoft UEFI Certificate Authority**. (Without this, the Ubuntu ISO will not boot).
3. Installed from the standard, official Ubuntu Desktop 24.04 ISO (Do NOT use Hyper-V's 'Quick Create' feature).
4. During Ubuntu installation, **Require my password to log in** MUST be checked. XRDP will not work with auto-login.
5. Your Hyper-V host must have Enhanced Session Mode allowed in its settings. You can enable this via an Admin PowerShell on Windows:
```powershell
Set-VMHost -EnableEnhancedSessionMode $true
Set-VM -VMName "Your_VM_Name" -EnhancedSessionTransportType HvSocket
```
## Usage
**CRITICAL:** You must run it from the Basic Session console or via SSH.
1. Boot your VM and log in using the Basic Session (the standard Hyper-V window).
2. Open your terminal and run the one-line install command:
```bash
wget -qO- https://raw.githubusercontent.com/Arelius-D/ubuntu-24.04-hyperv-enhanced-session/main/setup_hyperv_2404.sh | sudo bash
```
*(Alternatively, you can manually download `setup_hyperv_2404.sh`, make it executable with `chmod +x`, and run it with `sudo ./setup_hyperv_2404.sh`)*
3. **Cold Boot:** Once the script completes, a simple reboot is not enough for the new kernel modules (`hv_sock`) to initialize correctly. You must completely power off the VM:
```bash
sudo poweroff
```
4. Start the VM again from Hyper-V Manager. You should now be prompted with the Enhanced Session resolution slider. If you don't get this behavior, simply press the icon from the top menu bar in the VM main window. Log in using the `Xvnc` session drop-down, followed by your username and password.
## Current Limitations / TODO
* **Audio:** This script currently focuses on getting a stable, high-performance video and clipboard session running. It does not compile `pulseaudio-module-xrdp` for sound redirection.
* **Polkit Color Manager:** You may occasionally see a prompt asking for authentication to "create a color managed device" upon login. This is a known harmless quirk that can be dismissed. (Has never happened to me, but worth mentioning).