Update: For a script to install and configure Enhanced Session Mode instead of running the command below manually, see:
Enhanced Session Mode Install Script
Microsoft is investing heavily in Linux and while doing so, the Linux guest support for their own hyper-visor (Hyper-V) was improved in the last years. While Ubuntu got a lot of love (Enhanced Linux VMs) and is already available as a “Quick Create” VM (Ubuntu Hyper-V Image) in Hyper-V, the other big Linux distribution Fedora was left behind.
In this blog post, I’ll provide a short tutorial how you can enable the Enhanced Session Mode for Fedora 28 guests on a Windows 10 host with Hyper-V. The Enhanced Session Mode allows full-screen RDP into the guest VM and working copy-paste between guest and host in both directions using the free Remote Desktop Protocol (RDP) imlementation xrdp.
Enable Enhanced Session Mode for Fedora 28
You need an up-to-date Windows 10 machine with Hyper-V enabled and a Fedora VM (Generation 2) which runs in Hyper-V.
Load Hyper-V kernel module
First, load the Hyper-V kernel module.
echo "hv_sock" > /etc/modules-load.d/hv_sock.conf
If the echo
command does not work, create the file with vim
and enter the line hv_sock
manually.
Set SELinux to permissive
Attention: This step lowers the security of your system significantly!
Open the file /etc/sysconfig/selinux
and set the line SELINUX=permissive
.
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=permissive # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted # SETLOCALDEFS= Check local definition changes SETLOCALDEFS=0
Recompile xrdp with Hyper-V support
To enable xrdp with Hyper-V support you have to recompile xrdp with the --enable-vsock
flag.
Install RPM tools with:
sudo dnf install rpmdevtools rpm-build
Setup the RPM directory hierarchy:
rpmdev-setuptree
This creates the ~/rpmbuild
folder where new RPM packages can be build.
Download the xrdp source code:
dnf download --source xrdp
Install the xrdp source code into the ~/rpmbuild
directory.
rpm -ivh xrdp-0.9.8-1.fc28.src.rpm
Resolve all build dependencies for xrdp
sudo dnf builddep xrdp
Enable Hyper-V socket support for xrdp by editing the ~/rpmbuild/SPECS/xrdp.spec
file. Add --enable-vsock
to the configuration.
%configure --enable-fuse --enable-pixman --enable-painter --enable-vsock
Save and close the file.
Build a new RPM package from source:
rpmbuild -bb ~/rpmbuild/SPECS/xrdp.spec
Install xrdp
After you’ve build a new xrdp package with Hyper-V sockets enabled, simply install it as a service and enable it.
sudo dnf install -y ~/rpmbuild/RPMS/x86_64/xrdp-0.9.8-1.fc28.x86_64.rpm sudo systemctl enable xrdp sudo systemctl start xrdp
Configure xrdp
Edit /etc/xrdp/xrdp.ini
and set the values:
use_vsock=true security_layer=rdp crypt_level=none bitmap_compression=false max_bpp=24
Edit /etc/xrdp/sesman.ini
and set the values:
X11DisplayOffset=0
Create the file /etc/X11/Xwrapper.conf
and set:
allowed_users=anybody
Save and close the file.
Prevent xrdp from reinstalling
Fedora will update to an xrdp version without Hyper-V activated. To prevent this, disable the update for xrdp.
echo "exclude=xrdp" | sudo tee -a /etc/dnf/dnf.conf > /dev/null
Enable Enhanced Session Mode
Shutdown the Fedora VM and open a PowerShell on your Windows 10 host system. Type the following command and replace the VM name with the name of your Fedora VM.
Set-VM -VMName "Fedora VM Name" -EnhancedSessionTransportType HvSocket
Now, start the Fedora VM and the enhanced session dialog should pop-up. Go to Show Options --> Local Resources
and uncheck Printers
. Go back to Display
and check the Save my settings ...
checkbox. Click Connect
and a prompt asks for your Fedora user credentials. Enter them and use Xvnc
as the protocol.
Enjoy your Fedora with full screen support and copy-paste between guest and host in both directions!