Categories
IT and Tech

Hyper-V and Linux

After I completed my CISSP certification I wanted a break from all the studying and do something nerdy that I’ve been meaning to do but never got around to it. For me, this was doing a full Linux From Scratch build.

Back in the day I would just load up Linux on another machine to use as a host but since I now have my studio workstation at home with more cores than I know what to do with, I decided it might be a good idea to put it to work running some VMs.

Most of the VM’s I’ve worked with have predominantly been Type II hypervisors (meaning they run off a host OS) and every once in a while I’ll get to build a virtualization server using a Type I hypervisor. For some strange reason I completely forgot that Microsoft’s Windows Server Hyper-V is actually available on Windows 10 and 11 Pro.

With it being a Type I hypervisor, it meant that my VM’s don’t have the operating system overhead like a Type II normally would (read more performance), but more importantly, it also meant that if I wanted to run VMs in the background as a service, I totally could while I still use my workstation. Yeah, it’s probably not the best idea in a production environment but this is my house/home lab.

I’ll cover my LFS build in another post as I’d rather cover some issues I found while using a Linux guest OS under Windows Hyper-V.

Yes I know I could have just used WSL2 but I really didn’t want to mess with my main system all that much, especially since I’d likely be building and destroying many installs as I’d be testing a bunch of distros I’d like to use as the host. Technically speaking I could have just used ANY distro and then update the packages accordingly but I’d rather not muck around with that just to get my LFS build started.

For the most part, I ran into two common issues.

  1. Some distros just won’t boot or just get stuck in a black screen forever.
  2. When they did work, I couldn’t copy and paste from my host (My Windows box) into my guest (my virtualized Linux box).

Issue 1: Getting Linux distros to work properly

After looking at a few distros, I settled on the EndeavourOS pre-installation live environment as my host for my LFS build. However, for some strange reason I couldn’t get it to boot properly.

Found out after a bit of searching that this problem can be worked around by using the Quick Create feature under Hyper-V and unchecking “This virtual machine will run Windows”

After doing that, EndeavourOS booted fine!

Now it’s great that I got it to work but the problem is my main SSD where Hyper-V likes to defaults to doesn’t have that much space and I’d like to have my VMs sitting on a larger secondary SSD I have sitting around and set other options that the quick create menu doesn’t give me (like limiting the size of my virtual hard disk).

So now that I know Hyper-V will work, I just gotta figure out how to configure it manually so I don’t have to use the Quick Create and it turns out all I needed to do was disable secure boot under the host settings

This issue also replicates itself while I was trying to install some other distros, so if you run into the same problem. See if Secure Boot is enabled.

Issue 2: Getting Copy/Paste to work

Yes I know I really should manually type everything but sometimes, I just want to copy and paste text/urls/commands from my browser in my host machine into my VM. When I was running Virtual Box, I was fully able to copy/paste between host and guest no problem after I install the guest tools, but I couldn’t find any that I could use under Hyper-V and EndeavourOS.

Online searches didn’t bring up much other than making sure I have enhanced sessions turned on for both the Hyper-V server and the guest, which I already did but it just didn’t work for the life of me. Sure I could just use a browser from within the VM but I really didn’t feel like doing that.

Apparently the Ubuntu distros from the Hyper-V Quick Create menus have guest tools built into the distro but I couldn’t get it to work either.

The only solution that worked was using xrdp and instead of connecting through the Hyper-V manager (effectively running VMConnect), I’d have to run RDP and remote in.

Thankfully I found a script that sorts all that out for me. I couldn’t get it to work under EndeavourOS but it did work fine under Ubuntu (and it supposedly supports Debian as well).

xRDP – Easy install xRDP on Ubuntu 18.04,20.04,21.04,21.10 (Script Version 1.3) – Griffon’s IT Library (c-nergy.be)

Following the instructions, the installation was pretty painless.

  • Run wget https://www.c-nergy.be/downloads/xRDP/xrdp-installer-1.3.zip
  • Unzip the file
  • Set the script to executable (chmod +x)
  • run the script
  • LOG OUT OF THE SYSTEM (very important)
  • Run remote desktop connection

What works is the ability to copy and paste between host and guest OS’s. I initially ran into a problem where I’d RDP into the VM but would run into a black screen. Turned out it’s a known issue as the user that’s trying to remote in can’t be currently logged in. Logging out of any sessions solves that.

I disable printer sharing because printers always seem to cause problems and I don’t think I’ll need to print anything from my VM.

The sound redirection doesn’t seem to work even when I run the script with the sound redirection flag or run pulseaudio -k but I really don’t care about sound on the VM. Being able to copy and paste between host and client was the real win for me here.

Leave a Reply

Your email address will not be published.