Everyone is building more boxes and I shoved everything into one...
QUICK UPDATE 2016-04-20
A recent Proxmox update to the test repo brought shiny new things including a new 4.4 based Kernel, new GUI and LetsEncrypt support. All good things!
However, it currently messes up the PCI/E passthrough lines in your VM config file!
If you have followed this tutorial and since updated, you will need to open your VM config file again (as in Step 17) and fix the line!
You should be good to go again.
Power Consumption
Thought I'd update this as well. Got my cheapy power measurement in-line now. Typical power consumption is around 80-90W. Taxing the GPU under a gaming load takes it up to ~200W.
On first look, this might seem on the high side, but not surprising. The HDDs are quite old now and use about 5-6W each. With 6 of those we're using just 30W in drives. The Adaptec card is also a bit older and probably sucks down 25-30W on it's own (it sure dumps out plenty of heat).
Hi All,
Just thought I'd document and layout what I've been working on. A mission to get as much as possible into a single, quiet running HTPC box with how-to included for those interested. There's been tonnes of threads where peoples' homelabs are expanding into full racks with tonnes of gear (admittedly, some drool-worthy setups) and here I am going the opposite direction.
SO, for a long time I've been running 3 or more separate boxes. Usually something small as the router, a HTPC of some sort and a "Server"/NAS. Since I'm a gamer, the HTPC usually has to be something a bit gruntier than a NUC for TV gaming duty.
My last setup was something like this:
- Mini-Itx low-power (i3) router
- ATX Server/NAS (AMD FX8350) with VMs for downloaders/Sickbeard/Couchpotato/vent/teamspeak/gameservers/etc. Mass Storage was achieved with a USB3 external RAID enclosure (HotWay). The HotWay USB3 controller died which prompted this whole journey.
- HTPC with mid-range hardware (i5-3550, 750Ti etc)
One thing I'm particularly aware of is the power consumption of the entire setup. Particularly the FX 8350. It's a hungry animal of a thing compared to Intel offerings. It's also massively wasteful on resources. 99% of all of this is just sitting idle most of the time. The Server/router/HTPC literally do almost nothing during the day and yet remain on 24/7 to keep various services ticking over or available.
I've been a long time user of Proxmox through work (been running prod since PVE 1.1!). I love me some VMs. Hell, even the i3 router was actually Proxmox with the router itself being a VM. But, the one thing that I could never virtualise was the HTPC. It was simply too dependant on hardware features that couldn't be translated into a VM. HDMI output, audio and 3D acceleration for games/interfaces just wasn't a thing for VMs. BUT no more!
One thing that's been coming along nicely over the past year is PCI/E passthrough support. Particularly bypassing some driver issues (ie Nvidia detecting virtualisation and disallowing driver installation....) and streamlining the whole thing with the use of VFIO.
My first thought was to smash it all together into the FX8350 platform as it was by far the most powerful. But due to some silly incompatibilities (motherboard BIOS was handling IOMMU strangely) that idea got scrapped.
Opportunity came up to snag an i7-2600 which would work in my HTPCs Z77 Extreme4 board (which was total overkill for the i5-3550 that went into it at the time, but they were so cheap!) so I got to work on a grand re-shuffling of hardware, including a new HTPC case.
Now to the good stuff.....
Hardware:
- CPU: i7-2600 (Sandy Bridge)
4 cores, 8 threads and decently fast. More importantly it supports VT-d for PCI passthrough. - Motherboard: ASRock Z77 Extreme 4
Trusty old board with a surprising amount of BIOS features and VT-d support that ACTUALLY works. I actually have 2 of these now... - Cooler: Noctua NH-U9S
- RAM: 2x 4GB 1600mhz Corsair + 2x 4GB 1600mhz G-Skill Ripjaws Just had this lying around really.
- GPU1: Intel iGPU from the i7-2600
This is particularly important. The motherboard allows the iGPU to override as the "default" GPU. This really only exists as a console to the Hypervisor in case of emergency, but handy nonetheless and saves needing an extra GPU just for the host. Keep this in mind if you go with a Xeon as they usually don't have the iGPU onboard. - GPU2: ASUS 750Ti STRIX
This is the HTPC/gaming GPU that gets passed through. Nice and low power, good performance and nifty 0-fan mode to keep it quiet when idling. - NIC: Intel Gigabit 82574L PCIE 1x
- SSD1: 250GB Samsung 850 EVO
This is the "boot" drive for Proxmox. I also use to store the boot drives for the HTPC VM and downloader VMs. - HDD1: Seagate 2TB Barracuda
This is the "data" drive I'll be using for the VMs. Notably, somewhere to store games for the HTPC and working ground for the other VMs. No redundancy required as nothing of importance really goes on there. - RAID: For mass media storage I've got an Adaptec 5805 with 5x2TB (Samsung Spinpoint) drives attached in a single RAID5. If you have enough SATA ports on your MOBO you can just use the native ZFS/RAID-Z support in PVE now. Mine doesn't have enough and I just had this lying around so it got used.
- PSU: Corsair RM650x
80+ Gold rating, higher than usual 50C operating temp and fully modular (fighting for space already) - CASE: Silverstone LC16M ATX (Black)
Got this thing cheap because it was old stock. Slick brushed front, media knob and buttons, VFD LCD, IR remote, 6x 3.5" Drive slots, 2x 5.25 slots (1 internal), lots of fan mounts (1x 120mm in front of each drive cage, 2x 92mm rear exhausts) and enough height to fit the Noctua NH-U9S. - INPUT Devices: Rapoo mini wireless keyboard/mouse combo (HyperVisor), Logitech K400 wireless combo (HTPC), XBOX 360 Controller (HTPC)
2 keyboards here because one needs to be passed through to the HTPC so you can control the damn thing! But when you do this, it's "removed" from the host/hypervisor so a 2nd keyboard is a must.
Software and VMS:
- Hypervisor/NAS: Proxmox 4.1. It's free, Debian based with virtualization using KVM + LXC and has a nice Web GUI. Most importantly, the web console viewers are HTML5 now (no god-awful Java, woo!). My NAS requirements are pretty darn simple, so I'll actually be doing this entirely with the NFS server and Samba server packages which are easily installed. You could make the NAS a separate VM if you so desire and pass-through a RAID controller or use LVM to directly access disks.
- Router VM: This will be running PfSense. Alternatively you could run VyOS or whatever else.
- HTPC VM: This is the crown jewel. GPU and audio passed through so it appears natively. I can even overclock the GPU from inside the VM. With the 750Ti it has no problems with gaming as well (Xbox controller passed through). Currently hooked up to a 4K TV as well (30hz only unfortunately)
- Downloader VM: This will run the usual gamut of Sab/Sick/Couch/etc and act as a background organiser of media. When/If the KODI server branch is finished I may run that in here as well.
- Other: No doubt I'll have others running ventrilo/teamspeak and whatever else I feel like playing with. Notably, more powerful systems could run GPU assisted encoding like PLEX (including Quick-Sync if you passthrough the Intel iGPU). Or GPU rendering servers etc
HOW-TO EFI PCIE/GPU/USB Passthrough:
This is for EFI compliant GPUs. Anything newer than Nvidia 700 series and AMD r7/9 should be fine. You may have trouble with super low-end cards like the 710 which are old re-badges. All Intel iGPUs since Sandy Bridge support EFI natively.
Commands or config lines are in italics.
-
Boot up to the BIOS. First thing to check is VT-X and VT-d support. These are both Disabled by default on the old Z77 Extreme 4. More modern boards will usually enable VT-X and VT-d by default now.
-
Proxmox 4.1 base iso install. Installed to the SSD. The RAID card and 2TB data drive are disconnected as the PVE installer always installs the bootloader to the first drive detected (which is a pain in the arse). Multiple drives can screw with this sometimes. Once installed you can plug the other drives back in.
-
Add the Proxmox test repository as per: https://pve.proxmox.com/wiki/Package_repositories
The Test repo is required as it has the much-needed VFIO improvements. Then apt-get update && apt-get -y dist-upgrade to download the new packages and kernel. Dist-upgrade is required as kernel upgrades will not be downloaded by the default "upgrade" option for stability reasons. Once that's done, reboot. -
Create an additional bridge for the 2nd NIC. In the Network tab just use "Create -> Linux Bridge". It'll automatically be called vmbr1 and input "eth1" into the "Bridge Ports". Everything else remains blank. This is so the Hypervisor is not addressable on the WAN side (that would be bad). The only thing that should interact with the WAN side is the router VM. More on the router VM later.
-
Back to Passthrough stuff. Add "intel_iommu=on" and "pcie_acs_override=downstream" (NOTE1: see below) to your /etc/default/grub and run "update-grub" to apply changes. This is basically enabling IOMMU/VT-D support. Your boot line should look like this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on pcie_acs_override=downstream" -
Add modules to be started into /etc/modules. Just tack these in:
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd -
Next up, blacklisting modules. This is to prevent the Hypervisor from loading modules and taking over what you wish to pass through. In the case of GPUs it's easy. Add the following lines to /etc/modprobe.d/blacklist.conf (you can call it anything really):
blacklist radeon
blacklist nouveau
blacklist nvidia
That takes care of AMD and Nvidia cards. Furthermore, I'm also going to forward the onboard audio to my HTPC so better add those modules:
blacklist snd_hda_intel
blacklist snd_hda_codec
From there, add any more you deem necessary. For example, if I did actually want to forward my RAID controller, I'd add "aacraid" to that list etc. -
Check for which PCI card needs to be passed through. In the case of GPUs typically in the 1st slot. For most this is 01:00.0 (GPU) and 01:00.1 (HDMI). Handily, sub-devices like the HDMI ports can all be forwarded by just referencing the root device like "01:00". In my case the devices for my 750Ti are:
01:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2) 01:00.1 Audio device: NVIDIA Corporation Device 0fbc (rev a1) -
Time to create a VM! I'll be using the EFI boot method as defining hardware is easier and doesn't require anything else OS specific. I'll be using Windows 10 so going through the GUI I set the following options:
OS = Windows 8/10/2012
ISO = Win10 iso you can upload through the GUI, or point to the Physical DVD drive if you have one
HDD = Set "Bus" to SCSI. Set the rest to what you need
CPU = Whatever you like here. Keep "type" on "Default(kvm64)"
RAM = As you want
*NETWORK = Use default Bridged mode and select vmbr0 (your LAN). Change Model to VirtIO for best performance. VirtIO is a 10gbit paravirtualized bridge so your VM->VM and VM->HOST (ie NAS) are less likely to be network bottlenecked which is particularly useful if you have SSD storage.
Confirm -
Once the VM is created, there's a couple of extra bits we need to do in the GUI.
Go to the "Options" tab for the VM and change "SCSI Controller Type" to VIRTIO. -
Next up, change "BIOS" to "OVMF (UEFI). This is very important. If you forget this, you'll have to re-install.
-
You'll need the VirtIO Drivers for Windows for both Network and SCSI controller. You can get these in an ISO here: https://fedoraproject.org/wiki/Windows_Virtio_Drivers
Then upload it via the GUI. You'll want the latest "virtio-win.iso". -
Fire up the VM and start the Windows Installation via the Web Interface "noVNC" console. We'll add the USB/PCIE devices after.
-
You'll probably notice that no drives show up. That's because it needs the VirtIO driver from above. While the VM is running, edit your DVD device in the web-gui and select the VirtIO ISO file. Now back on the console you should be able to "add driver" and let select the relevant driver out of the "vioscsi" folder on the virtual DVD driver. Use the Win2012 driver for Windows 10.
-
Once the SCSI driver is installed your drive should show up. Now you can change the connected DVD back to the Windows ISO or physical drive. Hit the "refresh" button and you should be able to Partition/Install.
-
Get Windows running as you like. I also recommend grabbing GPU drivers and anything at this stage as well as doing Windows updates. Furthermore, it's a good idea to get RDP/Teamviewer up and running in case it goes pear shaped.
-
Next we need to manually modify the VM config file. This is located in /etc/pve/qemu-server/<VMID>.conf. For the GPU, add the following line:
hostpci0: 01:00,pcie=1,x-vga=on -
I'm also adding the sound-card. It's basically the same method but without the vga tag:
hostpci1: 00:1b,pcie=1 -
While you're there, another line needs to be added:
machine: q35
This seems to get around most driver detection issues. NOTE3 For Quadro/Tesla. -
One last command since this is using a Nvidia card:
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
This fixes up some benchmark/info programs from playing funny when detecting hardware. -
Time for USB devices! There's 2 ways to do this. I'm using the device ID method. This should ensure it passes through the device even if it gets plugged into a different port. The other method is by physical port. The port method can be handy if you want to "dedicate" a physical port to go to your HTPC. Nifty for front-header USB where you may plug external drives or usb sticks in (NOTE2 see below).
So, you'll need to run "lsusb" to find out what you need and you'll get some stuff like this:
Bus 006 Device 004: ID 045e:0719 Microsoft Corp. Xbox 360 Wireless Adapter
Bus 006 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 005 Device 003: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
This is what I want passed through to mine so take note of the "ID". -
Open up your VM config again (same as step 13). Add some lines for USB devices like this:
usb0: host=046d:c52b
usb1: host=045e:0719
usb2: host=0bda:0151 -
Start up your VM. At this point the noVNC/HTML console will NOT work (including input). You'll need to make sure you have a screen plugged into your passthrough GPU as well as keyboard/mouse passed through to control it.
-
Install GPU drivers. I stuck to Nvidia 359.06 because new drivers have been dodgy for regular users, nevermind VMs.
-
Done! With the GPU passed through and keyboard it should be basically like a regular PC as far as the user is concerned.
Conclusion:
Ran Firestrike benchmark on mine (only 4 cpu cores assigned) and it works well:
http://www.3dmark.com/fs/7901281
For comparison, here's an older Firestrike I did with the same GPU in a Haswell i3 (2core+HT which should come up similar):
http://www.3dmark.com/fs/2590500
GPU actually goes up, but that's probably to do with newer drivers. The slower Haswell cores are much more efficient than the old Sandy Bridge ones though so the CPU side will appear weaksauce.
So, I succeeded. Down to 1 box from 3 (or more). With how fast CPUs are getting now the limit really is in what you can stuff into a box. For home-lab purposes it's great and largely achievable with desktop hardware.
For someone looking to get into it with new hardware, you could build a serious box with the new Xeon E3-12XXv5 offerings matched with the C232/C236 motherboards coming out (supports VTX, VT-d and ACS for the best combination). The ECC support there would be particularly handy for ZFS being the NAS as well. Throw a dumb HBA card at it and SoftRAID will work a charm for NAS duties. You can get Xeon E3 processors with the Intel GPU still enabled as well.
Alternatively, you could build a bit cheaper with an i7-6700 or similar. From what I'm told all of the Skylake chipsets support VT-D out of the box and not just the higher end Z170 chipset, so pick whichever has features best suited to you.
UPDATE 2016-04-20 Worth noting as well, all of this is just as applicable to full servers running Xeon E5 as well as some of the new Broadwell Xeon D-15XX offerings. There's great potential with some of these new boards like this:
http://www.supermicro.com.tw/products/motherboard/Xeon/D/X10SDV-7TP8F.cfm
Up to SIXTEEN cores (32 Threads) at 65W, DDR4 ECC, super fast M.2 PCIE slot, 6x Gbit LAN, 2x 10Gbit SFP+ and onboard LSI 2116 RAID/HBA controller with SAS2 connectors! Absolute monster of a board. Even though the slot is only 8X, it has an open back so you should theoretically be able to stick a full X16 GPU in there and simply run it on 8 Lanes only.
NOTE1: You only need "pcie_acs_override=downstream" if you're using an Intel i series processor that is NOT LGA2011 based or AMD. Basically, when using IOMMU/VT-d, PCIE devices are grouped up then forwarded. Problem is, with small socket Intel CPUs and AMD these groups cover MULTIPLE slots. In my case, both PCIE x16 slots are part of IOMMU group 1. This resulted in my GPU AND RAID card being passed through to VFIO at the same time which is not good since I need that RAID card in the hypervisor still. This is generally considered unsafe due to the potential ramifications of misdirected communication. In my case, it looks like ACS is simply a present, yet disabled feature. This may NOT be the case with AMD or other Intel CPUs (particularly lower end ones).
NOTE2: USB devices can be complicated. USB3 and USB2 devices are treated separately. Furthermore, some USB sticks don't play nice with the easy vendor:product ID system and may require the port method used instead. Furthermore, if you have multiple of the SAME device for some reason (e.g 2 XBOX controllers) then you'll probably have to use the port method as the vendor:product IDs will probably be the same.
On a related note, all Intel Xeon CPUs (including small socket E3) support ACS which allows you to have unique groups per device.
NOTE3: For Quadro, Tesla and other Nvidia Workstation type cards you'll need to add another line to your VM config like this:
args: -machine pc,max-ram-below-4g=1G
Tested this myself with a Quadro K620 and it would not boot without it.
If there's any questions or suggestions then I'd love to hear them. This is actually the closest to "production" I've actually taken GPU passthrough so there's a lot of new stuff going on here.
Sources/Links:
Proxmox Wiki:
PCI Passthrough: https://pve.proxmox.com/wiki/Pci_passthrough
USB Port mapping: https://pve.proxmox.com/wiki/USB_physical_port_mapping
USB Device Passthrough: https://pve.proxmox.com/wiki/USB_Devices_in_Virtual_Machines
Posted Mar 22, 2016, 4:02 AM UTC · edited
I don't understand why you would leave your HTPC on all the time? My HTPC is a beast for gaming, but I just turn it on when I'm going to game for a while or watch a movie, but I don't care to have it always available like a file server, and it doesn't do anything in the background. If it's being used, I will be sitting at the HTPC, so there is no need for it to be on all the time.
It's left on mostly due to keeping the library up-to-date. Kodi doesn't have a simple remote library system yet. Hopefully it's coming soon-ish. Currently just using the alert system build into sick/couch to trigger library updates.
Even though it was on 24/7, it's power footprint at idle was fairly low as it wasn inevitably the newest of all my boxes.
Sure it does.
Use the MySQL Backend, and configure it to run on another computer to run the updates (such as on your NAS). Or use the Kodi - Emby bridge plugin and use Emby as the backend.
There are absolutely options here.
Yep the Emby plugin works great for this
I've looked at the SQL backend but I do a lot of version hopping within Kodi which presents problems. I'm currently playing around with both the 17.0 nightlies as well as the RetroPlayer fork. Usually I just stick to the regular backend and re-scan whenever I switch.
Not the best solution, granted I haven't looked at the MySQL backend since around v14 so I may have to do that again.
AH, that would still be an issue then, as the version compatibility stuff really hasn't been fixed.
Though, the emby/kodi bridge may work for you.