I’d Run Two Operating Systems at the Same Time, Man

Published on 2021, Oct 5

I have an incredibly stupid computer setup but the important thing is that it isn’t completely broken, and it could be not-quite-garbage for you too.


Jump to Process

One of the classic problems in applied computer science is that Linux is a good operating system1 for running compilers and other computer-programmer software, but Windows is a good operating system for running “everything else”, or “having a graphical environment that works”.

These two goals are sometimes in tension, especially when considering that switching between them typically requires completely rebooting the computer, or badly emulating one inside the other.

Fortunately, both Microsoft and the greater Linux community have spend a decade and change making their systems capable of being run in and/or as a virtual machine, that is, another operating system launches them as if they were a single, very large, program, and they themselves think that they are just in a weirdly slow computer. This technology isn’t perfect, and usually the first OS to boot has privileges and more hardware access that the second OS does not get to use, but it does mean we have some options for hosting multiple systems on one box, simultaneously:

A snippet of the manga “Densha de D” where an electric streetcar is made to
jump tracks and slide sideways down four rails rather than the traditional
two.

I have been doing this personally for about three years now, and interested in attempting it since about 2016. This is my story.

Attempt the First

When this story began, I was running Arch Linux as my primary full-time OS, but occasionally I wanted to switch over to Windows so that I could play Skyrim. My first thought was that I could just use Qemu to boot my Windows disk, pass in a GPU, and go on my way.

Unfortunately, I had made the foolish choice of “purchasing the same GPU twice”, and at the time (2015), Linux was incapable of distinguishing between multiple instances of the same GPU when attempting to perform “IOMMU passthrough”.

That is the term you should use when attempting to look up how to accomplish this. As I did not accomplish it, I will not talk about this anymore.

So I gave up, and then some stuff happened, and then I got a job and moved across the country, and I didn’t have a whole lot of time for video games.

Attempt the Second

Eventually some more stuff happened and I decided I did have some spare time and wanted some nice pleasantries around. So I decided to invert it: I decided to live in Windows full-time, and attempt to boot Linux as a guest virtual machine.

I already had my existing Linux installation, and didn’t want to damage it. Furthermore, I didn’t want to use a virtual hard disk image, because that just feels offensive to me. This is the setup that I’ve been using for the past three years, so it’s what I’ll actually describe.

Process

The exposition is done; this is all instructions now. Step zero: prereqs.

Prerequisites

Your Windows and Linux site installations cannot share disks. Hyper-V takes over the SATA access to each drive given to it, so drives used by Windows are ineligible for Hyper-V access and drives given to Hyper-V are invisible to Windows.

This includes your EFI System Partitions! Hyper-V will not mount the ESP that contains the Windows bootloader, because it is almost certainly on the drive that contains your running Windows installation. If this ESP also has a bootloader that launches Linux, it will not be available. You can either create a separate ESP, or you can rely on the fact that the vmlinuz-linux image is an EFISTUB program that Hyper-V can boot.

Dividing the Drives

Open the Disk Manager program (Win+x,k) and determine which drives are associated with your Linux installation. Windows will

So I set about looking up how to boot a Linux VM that had direct access to existing hard drives in the system. The native Windows VM host, HyperV, allows this directly! You just can’t let Windows itself try to use those disks. In Linux, this is easy: simply don’t mount any filesystems that live on them. In Windows, it’s slightly more annoying, but still pretty easy: you just go into Disk Manager and take the drives offline.

If you have a shared drive with multiple partitions on it, one or more for Linux and one or more for Windows, you are Shit Outta Luck. This is drive-level passthrough, not partition-level. Re-arrange and try again.

Picture goes here

Once the drives are offline, you need to

Footnotes

  1. Yes I know “Linux” is just the kernel. I will happily accept that GNU is a “system”, but I will vigorously reject the notion that it is “operating”.