Ubuntu 24.04.1 on Hyper-V
Amazingly enough, it turns out to be non-trival to get Ubuntu 24.04.1 running on a 4K high resolution display on Hyper-V. During the process I experienced crashes during installation, disk read errors, hangs, black screens during boot and login - and difficulties achieving a connection with full resolution on my 4K display.
In some configurations, the high resolution was just not available, specifically this was where the linux-azure cloud package was installed. Apparently this only supports lower resolutions out of the box. I'm sure it's possible to tweak this, but as everything else Linux it's practically impossible to find useful documentation.
When I finally got an image working reasonable well, it turned out that the screen scaling was not saved between reboots. I have no idea why, but I did find a remedy.
What follows is a basic step-by-step action list that at least got things working for me with no hitches during the process. Your mileage may vary, but there should be some useful hints here.
Here goes.
Download a .iso image
Get the current image from https://ubuntu.com/download/desktop
"The latest LTS version of Ubuntu, for desktop PCs and laptops."
Download 24.04.1 LTS (At the time of writing this was current)
This downloads for example: ubuntu-24.04.1-desktop-amd64.iso
When downloaded, startup Hyper-V Manager, and under the Actions pane select:
Quick Create...
Select the ISO image:
Local Installation Source -> ubuntu-24.04.1-desktop-amd64.iso
Uncheck "This virtual machine will run on Windows (Enables Windows Secure Boot)"
Under More options:
Name: "Ubuntu 24.04 LTS" (...or whatever you want to name it)
Click: Create Virtual Machine
Edit settings: Uncheck Use Automatic Checkpoints (may be the cause of black screens and hangs), Integration services check "Guest services" ("Ensuring it then says All services offered")
In the window "Virtual machine created successfully", click "Connect", and then start the virtual machine.
"Try or Install Ubuntu", accept all default choices except language and keyboard according to your situation.
Reboot as instructed, complete installation
In Ubuntu: Software Updater - install all updates, "Restart now"
Open terminal:
# This was part of the hard-to-find secret sauce...
sudo apt update
sudo apt install linux-image-extra-virtual
sudo nano /etc/default/grub
Edit
# Use your native resolution....
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:3840x2160"
Save
sudo update-grub
Shutdown
In the Windows host, open powershell in administrator mode and using your VM name and your native resolution as above:
set-vmvideo -vmname "Ubuntu 24.04 LTS" -horizontalresolution:3840 -verticalresolution:2160 -resolutiontype single
Startup the Ubuntu virtual machine again and log in.
If scaling is needed, set scaling in settings to for example 200%, and also to make it "stick" after reboot
open terminal and do:
# This was also non-trivial to figure out...
gsettings set org.gnome.desktop.interface scaling-factor 2
Reboot and confirm that it all works as expected and no settings have reverted.
Create a checkpoint
Now is probably a good time to shutdown again and create a manual checkpoint.
Credits
A lot of the above is found in various parts in this thread: https://superuser.com/questions/1660150/change-screen-resolution-of-ubuntu-vm-in-hyper-v . But it's about various versions and distributions, and there are also some digressions. No mention of crashes and black screens, which did appear to go away once automatic checkpoints were disabled. This post is specifically about Windows 11, Hyper-V and Ubuntu 24.04.1 .
No comments:
Post a Comment