Ubuntu Server 18.04 LTS cannot change resolution in Hyper-V

15,222

Solution 1

I changed both the CMD_LINE_DEFAULT and the next CMD_LINE with the same value (resolution I wanted), updated then rebooted, and it worked.

Like this:

GRUB_CMDLINE_LINUX_DEFAULT=video=hyperv_fb:1366×768
GRUB_CMDLINE_LINUX=video=hyperv_fb:1366×768

Solution 2

Since this question was asked (re ~ Ubuntu 15.04) things have progressed significantly with regards to Hyper-V & Ubuntu 18.04.1 with regards to ‘Enhanced Session Mode’.

There are two approaches currently:

A. New System ~~ Optimized Ubuntu Desktop images available in Microsoft Hyper-V gallery

B. Existing System ~~ manually configure xRDP to support ‘Enhanced Session Mode’

Here are the details:

Option A)

  1. In Hyper-V, on your server & select [Quick Create]
  2. In the [Create Virtual Machine] dialog, select [Ubuntu 18.04.1 LTS] && then [Create Virtual Machine]
  3. Then complete the standard Ubuntu installation options
  4. ‘Enhanced Session Mode’ will prompt you to setup screen resolution, local resources, etc.
  5. Note/Caution ~ if you have problems using drives, then you may want to de-select the [Printers]

Here are the links to where I sourced the information:

Optimised Ubuntu Desktop images available in Microsoft Hyper-V gallery

Run Ubuntu virtual machines made even easier with Hyper-V Quick Create

Option B)

  1. Modify Ubuntu 18.04 to use xrdp

    1.1 Get the scripts from GitHub

    sudo apt-get update
    sudo add-apt-repository ppa:git-core/ppa
    sudo apt update; sudo apt install git
    git clone https://github.com/jterry75/xrdp-init.git ~/xrdp-init
    

    1.2 Make the scripts executable and run them...

    cd ~/xrdp-init/ubuntu/18.04/
    sudo chmod +x install.sh
    sudo ./install.sh
    reboot
    

    1.3 <After Reboot> Run script again to finish setting up VM

    cd ~/xrdp-init/ubuntu/18.04/
    sudo ./install.sh
    
  2. Shutdown Ubuntu VM

  3. Register Ubuntu Session ~ run this command on host PC using powershell with admin rights:

    Set-VM -VMName YourUbuntuVMNameHere -EnhancedSessionTransportType HvSocket
    
  4. Restart VM

  5. Connect/Login to XRDP from Hyper-V (note ~ enter username - must be lowercase)

  6. Note/Caution ~ if you have problems using drives, then you may want to de-select the [Printers]


Here is the link to where I sourced the information:

Share:
15,222

Related videos on Youtube

badger_8007
Author by

badger_8007

Updated on September 18, 2022

Comments

  • badger_8007
    badger_8007 over 1 year

    I am testing Ubuntu Server 18.04 LTS using a Hyper-V VM running from Windows 10 1709, but so far I have been unable to change the console resolution. I have already installed the virtual services, modified grub file, updated grub config, but it does not work, the resolution always stucks at 1152x864 pixels.

    I have another VM running Server 16.04 LTS and there it works flawlessly.

    This is all the config I have done

    1. Update repositories.
    2. Install linux-virtual, linux-cloud-tools-virtual, linux-tools-virtual
    3. Verify the hyper-v daemons are loaded with lsmod (they are)
    4. Modify the file /etc/default/grub with the following GRUB_CMDLINE_LINUX_DEFAULT=video=hyperv_fb:1024x768 and running sudo update-grub
    5. Reboot the VM.

    I would be glad if someone can shed more light to know why it's not working or if there is a new trick to apply with this version.

    • Admin
      Admin almost 6 years
      Make sure you have created a Generation 2 virtual machine.
    • Admin
      Admin almost 6 years
      Thanks for the info but it is a Generation 2 VM indeed. So far I haven´t found aything documenting a change on this process, but knowing the underlying changes to other components (networking, etc.) made in this version, will not surprise me you have to modify aditional files or configure it in another way to get it working.
    • Admin
      Admin over 5 years
      Did you solve your issue? I am stuck on 1024x768
  • Emmanuel
    Emmanuel almost 6 years
    Actually you must run update-grub before to reboot.
  • verdy_p
    verdy_p almost 6 years
    Does not work for me, I constantly get a "package not found" error, can't install these components. the repositories seem to be removed or incompatible with current version of Ubuntu (no longer "xenial")
  • Pieterjan Spoelders
    Pieterjan Spoelders over 2 years
    Option A worked for me. Thanks!