Ubuntu Hyper-V Guest Display Resolution Win 10 + 15.04
Edit /etc/default/grub
with your editor of choice. Remember to use sudo
:
For example:
sudo nano /etc/default/grub
Change this line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
To this.
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"
Then in a console type:
sudo update-grub
reboot
Unfortunately, this is the highest resolution you can use for Linux Hyper-V guests.
Other virtualization solutions have guest additions which allow for higher resolutions like VMware and VirtualBox.
Note: If you have added the RemoteFX 3D Video Adapter in your VM settings you may have to remove it in order for this change to work. And do reboot your ubuntu guest for it to take effect.
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)
- In Hyper-V, on your server & select [Quick Create]
- In the [Create Virtual Machine] dialog, select [Ubuntu 18.04.1 LTS] && then [Create Virtual Machine]
- Then complete the standard Ubuntu installation options
- ‘Enhanced Session Mode’ will prompt you to setup screen resolution, local resources, etc.
- 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)
-
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
Shutdown Ubuntu VM
-
Register Ubuntu Session ~ run this command on host PC using powershell with admin rights:
Set-VM -VMName YourUbuntuVMNameHere -EnhancedSessionTransportType HvSocket
Restart VM
Connect/Login to XRDP from Hyper-V (note ~ enter username - must be lowercase)
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:
- Windows 10: A guide how to run Ubuntu 18.04 in Enhanced Mode in Hyper-V
For some reason, changing the grub config doesn't work on my Surface Book either (and I saw another Surface user complain about the same issue). I haven't found a solution yet, but here's something I can work with:
Install an X-Server for windows (e.g. xming), login to your virtual machine using ssh and set the DISPLAY variable (export DISPLAY= < your host ip>). You can also add that line to your ~/.bashrc to have it execute automatically when you login, otherwise you'll have to do that for each session.
This allows you to start your linux gui programms from ssh and work with them as if they were running natively on your host (much faster too, at least in my experience).
For convenience, I create an internal virtual switch in hyper-v and set up network sharing with that virtual device, so that my host always has the IP 192.168.137.1. This allows you to access the internet in the VM while having a static IP for your host.
Another solution which also works and gives you the full linux desktop experience (albeit slower than with X-forwarding over ssh): Install xrdp on linux as described here and use windows' remote desktop client to connect to your virtual machine. This will give you your native resolution, but is still a bit slow due to software rendering.