The Pragmatic Neckbeard's guide to Linux, KVM, ZFS and everything else in the world of Stallman and GNU.
AKA: How to steal Wendell's beard and get away with it
This is the first in a series of guides I plan to release on how to make the most out of your (admittedly overpowered) computer in a pragmatic way with Linux. In this first installation I'm going to simply discuss the requirements (physical, mental, temporal) and what you will get out of this in the end. The next article should be out within a week of this coming out.
That's nice and all, but what the hell are we doing?
Well, I'm so glad you asked. Essentially I'm switching to Linux but keeping Windows on the computer at the same time. The fact of the matter is that there are certain windows-only programs that I cannot live without. (Mass Effect and Skyrim, I'm lookin at you!) This means I'd either have to shut down my desktop and boot into windows every time I want to play a game, only to shut down and reboot into Linux to check my email, or, I just run a windows VM.
"But Kyle, VM's can't play games!"
Oh, Billy, you're so naive. That was true in 2004. Today, Virtual Machines can do almost anything a physical machine can, with very few exceptions. We accomplish this with a technique called GPU Passthrough. Essentially, we're going to tell the host machine to not use the GPU and give it to the Virtual Machine. With a bit of black magic and trickery, we can make this work.
I'm going to start this off by saying that I don't have a lot of money to spend on computers. This is the primary reason I'm not building some crazy powerful server capable of running the L1T forums on its own. Let's talk about the hardware I have at my disposal.
- CPU: i7-6700k
- GPU, Linux: R9 380
- GPU, Windows: GTX 970
- RAM: 16GB DDR4-2400
- HDD: 4x4TB RAIDZ1, 2x128GB SSD 1 cache/zil, 1 os (btrfs).
- Displays: 2x acer x223w, 1x A409u
I've got what I'd consider an upper-mid-range rig. Not quite 5820k, but not your average 3770. This all fits wonderfully within a Corsair 800D. I fully intend to put this under water at some point and push it to 4.6GHz, but that's not what this installation is about.
There are a few things people need to understand before they embark on this journey. First, you're going to want hardware cherry-picked to handle this project. While it's not absolutely necessary, you're going to benefit very much, in the form of less headaches and better performance, from having compatible hardware. That said, I recommend at least 8 threads (4 cores), 16GB of ram and an AMD fury series GPU for passthrough.
This project is not for the faint of heart. Not that you can't do it, but you're going to need an understanding of Networking, Linux and Windows.
Now that the warnings are out of the way, I can talk about the process and what it's going to entail.
1. Manjaro Linux
I'm using Manjaro Linux for a few reasons. First, it's like Arch. Second, it's not Arch. I know that sounds odd, but the fact is that Arch is a great OS, but arch needs constant maintenence to stay stable. I chose to use Manjaro because most of that maintenence is not required since Manjaro has it's own release cycle and stays mostly in sync with Arch while maintaining a higher level of stability. Manjaro also has a graphical installer wizard, which takes most of the headache out of installing Arch.
I'm using the arch package
linux-vfio for my kernel which has been specifically tailored for GPU passthrough which makes it the perfect kernel configuration for us. Along with passthrough-specific configuration, it also includes certain patches which will help with compatibility.
If you're following along, I'm going to make the assumption that you've got enough experience to install an OS yourself. Just choose the Manjaro install that you like best. I chose the i3 community spin.
It's probably clear by now that we're going to need a robust storage backend to support both the Linux host and the Windows VM. The clear choice for this is ZFS. There are a few benefits of using ZFS over BTRFS or LVM/EXT4 for our filesystem of choice which I'll enumerate here.
ZFS provides the best software RAID features on the planet. ZFS has managed to solve the Write Hole problem that plagues traditional raid solutions. ZFS supports thin-provisioned filesystems by default, along with thin-provisioned virtual block devices or volumes. ZFS has built-in read and write caching features, which can balance the benefits of SSD's speed and HDD's capacity for an incredibly powerful workstation. If this all isn't enough, ZFS checksums all your data and can tell if the data has been corupt and if you're using parity, ZFS can silently repair checksum errors. Just to put the icing on the cake, ZFS is Copy-on-Write, which means it doesn't overwrite data when it writes. This means ZFS can create an instant snapshot of a volume, filesystem or an entire array that only takes up space equal to the amount of data that's been changed. This makes ZFS an incredibly robust back-end for both your VM and your files.
The magical trio that makes your GPU go in your QEMU. No, that's not an inuendo, unless you want it to be.
IOMMU stands for Input/Output Memory Management Unit. At a very basic level, the IOMMU maps the PCI Express bus to memory addresses so you can read and write data to them. This will allow you to send your video card into a Virtual Machine and trick the machine into thinking it has physical hardware.
VFIO is basically a UEFI firmware for Virtual Machine's that allows you to perform passthrough. Along with allowing UEFI GPU's to initialize, it also supports UEFI bootloaders. This is helpful if you're using a very modern operating system. (Windows 8 or 10)
KVM, or Kernel-based Virtual Machine, is Linux' Virtualization system of choice. It's robust, and thanks to companies like Red Hat, its performance is at the top of the list. KVM boasts near bare-metal performance, within 1% of that of a physical machine, so it's the perfect option for what we're trying to do.
We're going to be using the
libvirt system with QEMU/KVM where QEMU is the middleware that will interact with the KVM subsystem. This is a perfect system for our use case because libvirt allows easier management through a gui and XML file.
5. More to come
I'm not the most organized individual. I'm trying to write down my thoughts as they appear, but I'm still working it all out. For now, be happy with this teaser. Ideally, I'll have them out on a weekly basis, but I have no plans for an actual schedule. (I am just too busy to commit to a day) Keep an eye on this post, where I'll be posting more information on my guides and topics. Also, when they come out, I'll be adding links inline so that navigation is easy.
This was just a brief introduction to my next few articles. I hope to captivate you in the next article, where I discuss ZFS and our storage options.