31

Last night I was attempting to set up a Ubuntu VM on my device using Hyper-V. I had no problems with creating the VM, nor getting OS installed inside it and booted (apart from I incorrectly chose Generation 2 the first time), however, I've been having problem with changing the resolution of the Virtual Host when connected to it.

I've done a decent amount of searching, and problem solving, but so far, none of my attempts have worked. Here's is what I've tried, and citations where I got the solution (where I could find them again this morning):

  1. Install Kubuntu 21.04 from their ISO and attempt to change the resolution in the display settings. No other options other than 1024x768 were present.
  2. Per this article amend the contents of the grub file:
    1. Open a Terminal.
    2. Enter sudo nano /etc/default/grub
    3. Alter the line starting with GRUB_CMDLINE_LINUX_DEFAULT to add the resolution setting. In my case, this was GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1200"
    4. Alter the line starting with GRUB_CMDLINE_LINUXT to add the resolution setting. In my case, this was GRUB_CMDLINE_LINUX="quiet splash video=hyperv_fb:1920x1200"
    5. Run sudo update-grub.
    6. Shut down the VM.
    7. Start the VM again.
    8. This resulted in a black screen, the VM was unusable.
  3. Install xrdp per the answer here on Ask Ubuntu and enable EnhancedSessionTransportType
  4. Install Ubuntu 20.04 via the Hyper-V Quick Create menus. No luck.
  5. Install xrpd on the Ubuntu 20.04 VM; no luck.
  6. Amend grub (as above). No luck

This answer also suggests that the max resolution is 1920x1080 (really not what I want, I have a 1920x1200 display, I'd like to use all the pixels), so i also tried using that in grub's setting, along with installing linux-image-extra-virtual. Still Kubuntu 21.04 I get 1024x768.

What can I do here? I know it seems daft, but this should just work. I have no problems with creating VMs in Gnome Boxes, both Linux and Windows, and being able to change the resolution. Why isn't this simple functionality in Hyper-V? It's literally impossible to use the VM in 1024x768 on a screen that is 1920x1200; the applicable menu alone in the VM takes up the entire screen, and using an IDE is, well, far from an enjoyable experience.

2
  • I also tried setting Enhanced Session Mode in Hyper-V Manager but that did not help. I continue to work on this. (now Insider Windows 11 Pro and same issue).
    – anon
    Commented Jul 1, 2021 at 11:17
  • Considering that some of the articles and Q&As I found date back to 2015, one would have hoped that this was an issue that Microsoft was both aware of and had fixed by now, @John . :(
    – Larnu
    Commented Jul 1, 2021 at 11:28

5 Answers 5

40

Below worked for me. Tested on Ubuntu 20.04 | Host Windows 11.

Open grub file.

sudo nano /etc/default/grub

Change value of GRUB_CMDLINE_LINUX_DEFAULT with below. Replace 3840x2160 with your highest resolution.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:3840x2160"

Run below commands

sudo update-grub

sudo apt install linux-image-extra-virtual

Shutdown the VM and open PowerShell as administrator on host machine and run below. Replace "ubuntu" with your vm name. Change "3840" and "2160" with your highest resolution.

set-vmvideo -vmname ubuntu -horizontalresolution:3840  -verticalresolution:2160 -resolutiontype single

This command may not be required. It is something I read on Kali blog.

set-vm "Ubuntu" -EnhancedSessionTransportType HVSocket

Start VM. Open Ubuntu Display settings and choose scale 200.

2
  • This looks to have worked; though you missed a step of needing to shut down the VM between updating the settings in grub and using Powershell to alter the settings of the VM. It's been a some time since I moved from trying to configure the VM, so I'm going to rebuild it and test again before I accept.
    – Larnu
    Commented Oct 12, 2021 at 15:19
  • tested and working on Windows 11 with Ubuntu 24.04
    – Edo Akse
    Commented Apr 19 at 8:43
41

I'm running Ubuntu 22.04 and only needed the following PowerShell command:

set-vmvideo Ubuntu -horizontalresolution:1920 -verticalresolution:1080 -resolutiontype single

(Replace Ubuntu with your VM name and the resolution with your monitor's resolution)

4
  • This is what did it for me - spent a couple of hours searching for an answer tried everything else. Then just this powershell one liner - great +1. Now if I could only fix the mouse lag :/
    – robs
    Commented Aug 3, 2022 at 10:30
  • Thanks! very elegant
    – shluvme
    Commented Dec 20, 2022 at 10:58
  • 5
    First to remove mouse lags do : sudo nano /etc/modprobe.d/blacklist.conf blacklist hyperv_fb save (ctrl + x then y) reboot After that do above step to fix resolution issue Commented Apr 9, 2023 at 3:47
  • 1
    just make sure to run powershell in admin mode - worked for me on win 11 and hyper v ubuntu 22
    – JGilmartin
    Commented Oct 26, 2023 at 18:37
2

On Ubuntu 22.04 this seems to be sufficient to set the resolution

set-vmvideo Ubuntu -horizontalresolution:3840 -verticalresolution:2400 -resolutiontype single

BUT in my case the scale wasn't being saved after rebooting the VM so I had to set the following in the Ubuntu terminal [xrandr didn't work out for me]:

gsettings set org.gnome.desktop.interface scaling-factor 2

(for scaling 200%)

0

If you've created your Ubuntu 22.04 VM by using the "Quick Create" function of Hyper-V Manager (which gives you a Microsoft-enhanced installation of Ubuntu) instead of installing your own ISO, the only solution that worked for me is:

  1. Make sure that the Ubuntu VM has been started but you must not have an RDP connection to the VM.
  2. Click on Edit Session Settings… for the VM in Hyper-V Manager.
    • If you've just started the VM, this menu option will not be there yet. You need to wait a minute.
  3. This will start your RDP session with the right resolution (and should remember it for next time).

Notice that the list of resolutions is quite limited.

-1

Using generation2 VM in HyperV using Windows 11 Pro this also worked. Below I attached to help. When inside the grub file (After typing in sudo nano etc/default/grub), be sure to use CRTL+G to view the HELP menu which displays all of the hot keys & commands offered.

Here are the precise steps I took:

  • I changed the two lines suggested with my resolution of 1920x1080

  • Then pressed CTRL+X to initialize exit of the grub file

  • Pressed Y and then ENTER to accept changes to file

  • Then typed in sudo update-grub and hit ENTER again.

  • I then typed in sudo reboot and reopened the session of Obuntu.

Tadaa, screen size fixed.

Syntax of my grub file

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .