Linux Fu: Windows Virtualization The Hard(ware) Way

As much as I love Linux, there are always one or two apps that I simply have to run under Windows for whatever reason. Sure, you can use wine, Crossover Office, or run Windows in a virtual machine, but it’s clunky, and I’m always fiddling with it to get it working right. But I recently came across something that — when used improperly — makes life pretty easy. Instead of virtualizing Windows or emulating it, I threw hardware at it, and it works surprisingly well.

Once Upon a Time

First, a story. Someone gave me a Surface Laptop 2 that was apparently dead. It wouldn’t charge, and you can’t remove the keyboard without power. Actually, you can with a paper clip, and I suggested pulling it to see if the screen would charge by itself. They said they had already bought a new computer, so they didn’t care.

Unsurprisingly, once I popped the keyboard off, the computer charged and was fine. You just have to replace the keyboard or use another one. Or use it as a tablet, which it is set up for anyway. But I have plenty of laptops and computers of every description. What was I going to do with this nice but keyboardless computer?

Coincidence

About this same time, I’d been moving my VirtualBox Windows installs over to KVM. That’s a pain if you’ve ever done it, but it performs well and works well. Then I found WinApps. This is a simple script setup that runs Windows in your choice of virtual machine and can pull a single application into an RDP client on your desktop. The effect is that you can have, for example, Microsoft Word just sitting on your desktop like any other program. It also wires up the application so you can, say, open a PowerPoint directly using a real copy of PowerPoint running in the virtual machine.

It works great, except for one thing. When Windows is running, your disk thrashes like crazy. That’s probably not very surprising since the Windows VM image is in a file, so everything goes through the Windows file system and then the Linux file system. Between my SSD cache and my RAID array, there’s a lot going on there. The performance wasn’t bad, but the disk going wild was annoying, and it would freeze up here and there while the drive was overwhelmed.

Virtually Reality, for Real

But what about WinApps? It points to a virtual machine in KVM or Docker. Why not let it point to a real piece of hardware on the network? I could put the Surface out of the way and then run my choice of Windows software right on my desktop with hardware speeds only limited by the network.

Rather than keep you in suspense, it worked. The program allows you to set your virtualization type and one of them is “manual.” Presumably, you’d usually start a VM yourself, but in this case, just the IP address of the remote Windows box is all you need.

Is it that Easy?

Well, almost. There were two small issues. For one thing, you need to run an install script on the Windows box. You can do that before you set up, while you enable Remote Desktop. Here’s what the directions say:

Next, you will need to make some registry changes to enable RDP Applications to run on the system. Start by downloading the RDPApps.reg file, right-clicking on the Raw button, and clicking on Save target as. Repeat the same thing for the install.bat and the NetProfileCleanup.ps1. Do not download the Container.reg.

The other issue is that I have two monitors that are separated, with one at the bottom left and one at the top right of a large rectangle, and lots of blank wall between them. The xfreerdp program hates that. I had to fiddle with the settings quite a bit, and you may have different results.

One thing I did to be safe was to go get the latest version of xfreerdp and install it. You can point to it in the WinApps configuration file. Sometimes, the programs in your distro’s repositories can be pretty old. I wanted to make sure I had the latest RDP client.

For normal operations, these options worked:

RDP_FLAGS="/cert:tofu /sound /microphone +home-drive /span /multimon:force /mouse-relative /dynamic-resolution"

I also had to edit ~/.local/bin/winapps to change the options for the “windows” run (which starts a full-screen windows session) to:

# Open Windows RDP session.
dprint"WINDOWS"
$FREERDP_COMMAND \
/d:"$RDP_DOMAIN"\
/u:"$RDP_USER"\
/p:"$RDP_PASS"\
/scale:"$RDP_SCALE"\
+auto-reconnect\
/monitors:0\
/wm-class:"Microsoft Windows"\
/t:"Windows RDP Session [$RDP_IP]"\
/v:"$RDP_IP"&>/dev/null &

Bugs!

While I was in there, I also fixed a bug. The script (and the installation script) can’t figure out that my user is in the right group to run virtual machines, so if you plan on using real virtualization, you might have to fix it or, do what I did, and comment that test out of the main program and the installer. However, if you are using manual mode, that shouldn’t be a problem. The installer also tells me that ~/.local/bin isn’t on my path, but it is. That’s safe to ignore.
There seem to be some other issues. For example, while the installer sets up the ~/local/bin directory, it didn’t add any links to my start menu. I think it was supposed to. Of course, it is trivial to just add your own menu items, which you’ll need to do for non-standard programs, anyway.

Proof in the Pudding

Word on Linux the hard way!

Does it work? Well, there’s Microsoft Word running on my KDE desktop. You might have to rearrange or resize a Window when you first launch it. If that bothers you, write a rule to fix the window position. Most of the time, it works well enough. You can also go full screen and back (Control+Alt+Enter). Anything you can normally do in a RDP session, you can do here.

Is it perfect? Nope. You can, in theory, redirect USB devices, but it will be kludgy and probably slow. I still use KVM for things that have to talk to a USB device. Of course, you can also hang the USB device off the Windows machine. The default setup maps your home directory to Windows, but you can fix it to map other places, too (and make sure the config file knows where your removable media mounts, too). The system autodetects many apps, but there is a manual mode that can, in theory, run anything. Or, you can pull up Windows Explorer and run any application you want.

This would be a perfect thing to use an old computer sitting around or a junk store small form factor PC that you can pick up for nearly nothing. You won’t be gaming on it or anything, but it is perfectly usable for that strange Word document or EPROM programmer software.

Honestly, it’s gotten to the point where having WSL on Windows means I barely notice which OS I’m on 99% of the time. Most of the apps I use will run on either system, but I still prefer the control I have on Linux and find it easier to fix issues there. At least dual booting is mostly a thing of the past.

22 thoughts on “Linux Fu: Windows Virtualization The Hard(ware) Way

  1. this is really cool :)
    my current issue : GPU sharing.
    my dream : getting autodesk inventor on linux but working inside a VM is just painful and I dont have two GPU to dedicate one to a VM.
    if someone has an idea i’m all ears.

    (I recently retried freeCAD and i’m impressed it’s nothing like the one I tested 2 years ago, maybe I should just learn FreeCAD instead :)

    1. Having been a FreeCAD user on and off through many of its growing pains and found it pretty useable even then – just got to learn the best practices for a new tool, which will feel really awful to start with. So I’d certainly suggest that is a plausible solution, but with a learning curve you may not like. Though one I’d suggest is looking less painful than riding the crashing Windoze ship into the ground…

      You shouldn’t need a dedicated GPU for the VM if the CPU on the host has intergraded graphics (which is pretty common), and that might be the cheapest change you can make if it doesn’t. But otherwise the only thing to suggest is trying WINE/Proton with Autodesk, never tried it or looked it up, but I’d actually be more shocked if it didn’t work after some fiddling than does these days.

      1. I tried with Wine, Proton, bottle. I saw that some managed to get Fusion to somewhat works. but Inventor does not and I never saw anybody succeeding.

        for the GPU sharing the integrated GPU to a VM is not easy ( tried withouth sucess). I can share a PCIE device like a full discrete GPU to a vm to get decent CAD performance but I also want to be able to get my GPU for my linux host (and since GPU dont like to be share they usually require a reboot if one want to pass it from the host to the VM and back)

        the proposed solution to have a remote computer and bring an app from that machine RDP style is great but it require to have a second device which is expensive and double the power draw :( but I could devise like a remote switch to power on and off my “cad” server.

        but yeah I might just learn freeCAD (I draw a lot on inventor and so far I manage to get the base feature to make simple part and assemble them with constraint which I did not succeed last time I tried)

        1. In theory I was suggesting you run the host and display through the iGPU always, making the PCIe GPU an accelerator you can use while it is available but the pipeline always has to go through the integrated GPU (As often done in laptops). Which makes that PCIe GPU being the one you’d pass through to the VM, and can in theory recover that extra horsepower when the VM releases without a reboot.

          Not an idea solution really, being something that always seems to be problematic at some point in the laptops that use that concept, but it should be workable.

          But I would really suggest just learning FreeCAD is going to be worth it at this point. It keeps on getting better, and really is a fully capable tool.

  2. The ability to mix the windows on one desktop is kinda spiffy, but I would probably either run some flavor of VNC (if the Windows box is headless), or just add its monitor to my desk and use something like Synergy to control it.

  3. VMs are the way to go. Everything I need runs in Linux now so from SBCs to Workstations all run Linux. But trying out new Linux distros, or run an old version of Windows or DOS, a VM is the way to go. I have a VM for Free Dos, Win XP and Win 7 (last of the best), but rarely use them anymore.

    1. I also have VMs but they aren’t always very performant. I will say kvm seems better than VirtualBox I’ve stuck with forever. But even with 64 GB of memory and 24 CPUs running Windows on my box with any actual memory trashes a lot.

      1. I guess I haven’t noticed on my AM4 Ryzen based systems. What I have noticed is the VMs seem ‘really’ fast. Definitely way faster than the original bare-metal systems of the time whether running under VirtualBox or kvm. Only time I run into real ‘noticeable’ degradation is running, say, a youtube video full screen inside a VM. Note that I don’t allow the Windows/DOS system access to the internet ever). But since I don’t use VMs for video stuff, VMs are quick enough. Leave video/graphics for the bare-metal system. My main VM machine is my workstation with 64GB DD4.

        1. Yeah running a video or any 3d application on a virtual machine almost always means CPU decoding and rendering, often on the virtual cpu to have that little extra overhead from the virtualisation – so that usually will really gobble up resources.

          If you have a linux OS as host and guest VirGL in theory works to let your VM use your hosts GPU for acceleration without actually having to pass through a full GPU (last time I used it actually getting it working was a bit wonky, but once it does work it is great), and you can of course give a VM basically native access to the hardware with pass through.

          1. Virtualbox featured experimemtal 3D acceleration for Windows XP.
            It used to use WineD3D to patch Direct3D 8/9 runtime in Windows safe-mode.
            On host side, OpenGL would then render the 3D graphics.
            Unfortunately, this feature was removed somewhen in Virtualbox 6.1 for security reasons. Sigh. 😮‍💨
            There’s not always progress, unfortunately. Newer isn’t always better. 😟
            For high-end retro fans now have to use Virtualbox 7 and SoftGPU on Windows 98SE.
            Yeah, Windows 98SE instead of Windows XP!
            Luckily, there’s KernelEx project, so many XP era applications and games can run on Windows 98SE..
            It still feels odd to “downgrade” to Windows 98SE in order to technically “upgrade” the gaming experience.

            (Windows XP still runs perfectly good on PCem/86Box, but that’s 100% emulation.)

      2. You might find it worth creating a new partition or just slotting a small windoze OS drive into your system in that case, its how I always did my windoze VM’s in part because I was just reusing the old SSD that used to be the dual boot drive.

        Though honestly that sounds like a problem you’d have with Windoze even running natively should it be running on a RAID array of spinning rust as windoze is forever doing a little something here and there with your hardware in the background these days.

    2. You could do that in 1994 on a 386 running DESQView/X already, I think.
      Windows 3.1x was running in an X11 window, which also could be accessed via remote desktop connection.

      Running WABI on Solaris or Linux desktop was another option, too.
      It ran Windows 3.1 386 Protected-Mode kernel natively on *nix, without needing any DOS.
      That way, Windows applications ran just like any other *nix program (or or less) and could use system resources.
      Thus, it could be remote controlled same way as other applications.

    3. It’s not as easy all time, though, because VM hypervisor software lacks a bit of diversity.

      For example, if you’re running something exotic such as Mac OS X Server.Good luck getting network or sound to work, when the VM doesn’t feature one of the 5 or so chipsets supported by OS X.

      Or, let’s take Windows 9x, which is beloved among retro gamers.
      Here, VMs have very poor support for standard hardware.
      No emulation of, say, a 3dfx Voodoo, S3 ViRGE, Nvidia NV1, Matrox Mystiqe etc.
      There’s no Sound Blaster AWE32 (with EMU 8000 synth) or Pro AudioSpectrum 16 emulation.

      Or, let’s take early CD-ROM drive emulation for OS/2 1.x, 2.0 or early Linux.
      Where’s support for Mitsumi Lu005S interface controller? Hm?
      It’s missing. Despite it being historically standard hardware.
      Same goes for graphics standards such as IBM 8514/A, XGA or XGA2.
      These were official IBM PC standards, yet they’re not available in VMs.

      For such things, someone has to use PCem or 86Box.
      They do support modt of the industry standard hardware, but are very demanding.
      Due to complexity, they’ll top out on Pentium II level.
      Above this, CPU design gets so complicated that it even takes the most modern hardware down to its knees.

      Here, it would be more feasible to use an virtualization on an x86, if possible.
      Or write new drivers for rare OSes such OS/2 1.x and Mac OS X Server to make them run with the existing virtual hardware that these VM virtualization software products provide to VMs.

  4. The invention of the tap water?

    Remote app tool works on any windows starting from Xp professional, and creates a special rdp file which recent version of freedom understand w/o even opening the command line.

    It’s like 15 years I use Wmc on Linux this way.

  5. I normally just had a second machine with monitor and then used something like Barrier/Synergy or similar software to share one Keyboard & mouse between the two desktops (Linux and Win).
    Many of these apps also allow sharing of clipboard so you sometimes forget it is different machine.

  6. For small files between ‘instances’ I use syncthing tray on the linux host(s) and synctrazor on the windows guests. All of them have a ~\sync folder that gets instantly replicated across the network (you can lock out the internet discovery part of syncthing so it only ‘works’ on the lan)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.