{"id":6,"date":"2017-02-28T16:25:42","date_gmt":"2017-02-28T16:25:42","guid":{"rendered":"http:\/\/www.dcellular.net\/blog\/?p=6"},"modified":"2017-02-28T16:25:42","modified_gmt":"2017-02-28T16:25:42","slug":"gpu-pass-through-with-linux","status":"publish","type":"post","link":"https:\/\/www.dcellular.net\/blog\/?p=6","title":{"rendered":"GPU Pass-through with Linux"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">This post is intended to get you up and running with GPU passthrough using Arch Linux and Windows. There are a number of different guides out there including the Arch wiki; however, I found that some detail was lacking for beginners. I also wrote this for my own sanity in case I break something or need to do this again.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">What is needed:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CPU that supports virtualization and IOMMU<\/span>\n<ul>\n<li style=\"font-weight: 400; text-align: left;\"><a href=\"http:\/\/ark.intel.com\/search\/advanced?s=t&amp;VTX=true&amp;VTD=true\"><span style=\"font-weight: 400;\">Supported Intel CPUs<\/span><\/a><\/li>\n<li style=\"font-weight: 400; text-align: left;\"><span style=\"font-weight: 400;\"><a href=\"http:\/\/support.amd.com\/en-us\/kb-articles\/Pages\/GPU120AMDRVICPUsHyperVWin8.aspx\">Supported AMD CPUs<\/a><\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"font-weight: 400; text-align: left;\"><span style=\"font-weight: 400;\">A motherboard that supports IOMMU<\/span><\/li>\n<li style=\"font-weight: 400; text-align: left;\"><span style=\"font-weight: 400;\">2x GPUs<\/span>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Anything newer than 2012 should work<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: left;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">One for the host to run and one for the guest that you will be passing through<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The Guest GPU must support UEFI<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Enough RAM for the guest and the host (this particular build is 32GB RAM)<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><i><span style=\"font-weight: 400;\">**Note: you must have two distinct GPUs. \u00a0This will not work if you have two identical GPUs<\/span><\/i><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Two monitors or a monitor that has two inputs (one monitor or input for each GPU)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">A Windows ISO<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">For this guide, I will be using the following:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Intel Core i7 6700k<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">ASUS \u00a0Maximus VIII Gene Motherboard<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Nvidia Geforce GTX 1070 (to be passed through to the Windows VM)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Intel SSD 600p Series 256GB M.2 SSD (for the host OS)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">SanDisk Ultra II 960GB SSD (to be passed through and dedicated to the Windows VM)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">32 GB Ram<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Arch Linux*<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Windows 10 64-bit<\/span><\/li>\n<\/ul>\n<p><i><span style=\"font-weight: 400;\">*Side note: My Arch install is currently using the linux-lts kernel due to a bug related to Intel Integrated graphics and the newest linux kernel.<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">With this particular configuration, the i7-6700K integrated GPU will be configured as the primary GPU for the host OS with the GTX1070 being used for the Windows VM. \u00a0<\/span><\/p>\n<p><b>IOMMU Configuration:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Virtualization must be enabled via the BIOS. \u00a0You will want to look for settings that say VT-d, VT-x, AMD-V, virtualization, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Next, enable IOMMU support via the bootloader. \u00a0Depending on your CPU, you will need to use:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">intel_iommu=on<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">amd_iommu=on<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">If using systemd-boot, run:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo vim \/boot\/loader\/entries\/arch.conf<\/pre>\n<p>Add the parameter \u201cintel_iommu=on\u201d if you are using an intel cpu or \u201camd_iommu=on\u201d if you are using an AMD cpu<\/p>\n<p><span style=\"font-weight: 400;\">Example of my arch.conf:<\/span><\/p>\n<p><a href=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.14.56-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16 size-full\" src=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.14.56-PM.png\" width=\"554\" height=\"71\" srcset=\"https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.14.56-PM.png 554w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.14.56-PM-300x38.png 300w\" sizes=\"auto, (max-width: 554px) 85vw, 554px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Check that IOMMU is enabled by running:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo dmesg | grep -e DMAR -e IOMMU<\/pre>\n<p>You should see a line that says \u201cIOMMU enabled\u201d<\/p>\n<p><span style=\"font-weight: 400;\">Example output:<\/span><\/p>\n<p><a href=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.16.33-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-19 size-full\" src=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.16.33-PM.png\" width=\"254\" height=\"19\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">To find the devices you will be passing through, list pci devices with:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lspci<\/pre>\n<p>Look for any devices resembling your GPU. \u00a0In this case I have a Nvidia GPU and Audio device:<\/p>\n<p><a href=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.18.22-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-20 size-full\" src=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.18.22-PM.png\" width=\"623\" height=\"38\" srcset=\"https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.18.22-PM.png 623w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-13-at-2.18.22-PM-300x18.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Keep in mind that we will need to pass both of these devices through as they are both a part of the video card.<\/span><\/p>\n<p><b>Kernel Modules:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Next, we will need to add kernel modules to be loaded before boot. \u00a0Using your favorite editor, open up the file mkinitcpio.conf and add the modules. \u00a0For this, I am using vim as the editor:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo vim \/etc\/mkinitcpio.conf<\/pre>\n<p><span style=\"font-weight: 400;\">Add the modules:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">vfio vfio_iommu_type1 vfio_pci vfio_virqfd<\/pre>\n<p><span style=\"font-weight: 400;\">An example of how they should be added:<\/span><\/p>\n<p><a href=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-07-at-4.56.02-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-17 size-large\" src=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-07-at-4.56.02-PM-1024x246.png\" width=\"840\" height=\"202\" srcset=\"https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-07-at-4.56.02-PM-1024x246.png 1024w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-07-at-4.56.02-PM-300x72.png 300w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-07-at-4.56.02-PM-768x184.png 768w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-07-at-4.56.02-PM.png 1034w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Exit and save changes.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Regenerate the initframfs config with:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mkinitpcio -p linux-lts<\/pre>\n<p><i><span style=\"font-weight: 400;\">**I have specified \u201clinux-lts\u201d since I am using the linux-lts kernel. \u00a0You can substitute \u201clinux-lts\u201d with \u201clinux\u201d or \u201clinux-vfio\u201d depending on the kernel you are using. \u00a0Tab-completing should give you the right one but chances are you will want the standard \u201clinux\u201d.<\/span><\/i><\/p>\n<p>At this point you should reboot to verify that the changes have taken place. \u00a0You will want to confirm that the vfio-pci module is loaded for the devices that you want to pass through with lspci.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lspci -nnk<\/pre>\n<p><span style=\"font-weight: 400;\">You are looking for the kernel driver in use to be set to \u201cvfio-pci\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Take note of the IDs associate with your GPU and the GPU\u2019s audio system. \u00a0In this case, mine are labeled \u201c10de:1b81\u201d and \u201c10de:10f0\u201d.<\/span><\/p>\n<p><a href=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-09-at-10.06.23-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-18 size-full\" src=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-09-at-10.06.23-PM.png\" width=\"762\" height=\"138\" srcset=\"https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-09-at-10.06.23-PM.png 762w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-09-at-10.06.23-PM-300x54.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Once it is verified that the kernel drivers in use are set to \u201cvfio-pci\u201d, the next step is to add the hardware Ids to the VFIO config file. \u00a0Use your favorite editor and open the file:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo vim \/etc\/modprobe.d\/vfio.conf<\/pre>\n<p><span style=\"font-weight: 400;\">Add the hardware IDs to options:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">options vfio-pci ids=10de:1b81,10de:10f0<\/pre>\n<p><span style=\"font-weight: 400;\">If the file <\/span><i><span style=\"font-weight: 400;\">vfio.conf<\/span><\/i><span style=\"font-weight: 400;\"> does not exist, make sure to create it and add the options line at the top of the file.<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">**Note: If you have other additional hardware you want to pass through, add it here. \u00a0We will not be adding a keyboard and mouse here as we will be using evdev to toggle input from the keyboard and mouse between the host and guest VM later on in the startup script.<\/span><\/i><\/p>\n<p>Save and exit the file and reboot.<\/p>\n<p><b>QEMU Setup:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Now that the hardware is configured, we will need to configure OVMF as the UEFI BIOS and QEMU. \u00a0Start with installing qemu and rpmextract<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo pacman -S qemu rpmextract<\/pre>\n<p><span style=\"font-weight: 400;\">Grab the compatible OVMF image from here: <\/span><a href=\"https:\/\/www.kraxel.org\/repos\/jenkins\/edk2\/\"><span style=\"font-weight: 400;\">https:\/\/www.kraxel.org\/repos\/jenkins\/edk2\/<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">We will be looking for the x64 version as we will be running a 64bit OS. \u00a0Once the download has finished, run &#8220;rpmextract.sh&#8221;\u00a0<\/span><span style=\"font-weight: 400;\">with the file you downloaded:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">rpmextract.sh edk2.git-ovmf-x64-X-XXXXXX<\/pre>\n<p><span style=\"font-weight: 400;\">A <\/span><i><span style=\"font-weight: 400;\">\/usr\/share\/<\/span><\/i><span style=\"font-weight: 400;\"> directory should have extracted. \u00a0Copy this over into <\/span><i><span style=\"font-weight: 400;\">\/usr\/share\/:<\/span><\/i><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo cp -R usr\/share\/* \/usr\/share<\/pre>\n<p><b>Configuring the Guest VM:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">At this point, you should be able to start QEMU from the command line or configure a GUI such as virt-manager. \u00a0For the purposes of simplicity, this guide will only\u00a0cover<\/span>\u00a0the command line setup. \u00a0To test out that everything is working, this base script can be run:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#!\/bin\/bash\r\ncp \/usr\/share\/edk2.git\/ovmf-x64\/OVMF_VARS-pure-efi.fd \/tmp\/my_vars.fd\r\nqemu-system-x86_64 \\\r\n-enable-kvm \\\r\n-m 1024 \\\r\n-cpu host,kvm=off \\\r\n-vga none \\\r\n-device vfio-pci,host=01:00.0,multifunction=on \\\r\n-device vfio-pci,host=01:00.1 \\\r\n-drive if=pflash,format=raw,readonly,file=\/usr\/share\/edk2.git\/ovmf-x64\/OVMF_CODE-pure-efi.fd \\\r\n-drive if=pflash,format=raw,file=\/tmp\/my_vars.fd \\<\/pre>\n<p><span style=\"font-weight: 400;\">Running this script should boot into a UEFI shell. \u00a0This will appear on the monitor that you have plugged into the GPU that is being passed through. If you are using a single monitor with two inputs, check the other input to see if it has booted. \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">With a successful UEFI boot, the next step is to specify and mount the installation ISOs and drive that Windows is to be installed to. \u00a0Grab the latest or stable VirtIO drivers from Fedora: <\/span><a href=\"https:\/\/fedoraproject.org\/wiki\/Windows_Virtio_Drivers#Direct_download\"><span style=\"font-weight: 400;\">https:\/\/fedoraproject.org\/wiki\/Windows_Virtio_Drivers#Direct_download<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">A few new lines will need to be added to our Bash script to mount the ISOs we have now so that they can be accessed by the VM. \u00a0Additionally, we will need to add our virtual or physical disk to install Windows to. \u00a0I have opted to dedicate a 1TB SSD to the Windows VM so this guide will not go in depth on creating a virtual disk.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Specify the devices to be accessed by QEMU:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-device virtio-scsi-pci, id=scsi \\&lt;\/span&gt;<\/pre>\n<p><span style=\"font-weight: 400;\">Add the disk that will be dedicated to the VM:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-drive file=\/dev\/sda,id=disk,format=raw,if=none -device scsi-hd,drive=disk \\&lt;\/span&gt;<\/pre>\n<p><i><span style=\"font-weight: 400;\">To find the path to the disk, use the \u201clsblk\u201d command in the terminal to list your available disks.<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">Specify the path to the Windows 10 ISO and the VirtIO driver image that we downloaded from Fedora:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-drive file=\/home\/dcellular\/ISOs\/Windows10x64.iso,id=isocd,format=raw,if=none -device scsi-cd,drive=isocd \\&lt;\/span&gt;<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-drive file=\/home\/dcellular\/downloads\/virtio-win.iso,id=virtiocd,if=none,format=raw -device ide-cd,bus=ide.1,drive=virtiocd&lt;\/span&gt;<\/pre>\n<p><span style=\"font-weight: 400;\">Finally, we need to address input devices to be shared with the VM. QEMU 2.6 saw the introduction of evdev input support which allows for switching input between the VM and host by hitting both CTRL keys at the same time. \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">**Note: <\/span><i><span style=\"font-weight: 400;\">If you are not running at least QEMU 2.6, input device switching will not work and you will need to grab a newer version. \u00a0Use \u201cqemu-system-x86_64 -version\u201d to see which version you have installed.<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">List your connected devices:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">ls \/dev\/input\/by-id\/&lt;\/span&gt;<\/pre>\n<p><a href=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-27-at-3.22.49-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-35 size-full\" src=\"http:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-27-at-3.22.49-PM.png\" width=\"413\" height=\"101\" srcset=\"https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-27-at-3.22.49-PM.png 413w, https:\/\/www.dcellular.net\/blog\/wp-content\/uploads\/2017\/02\/Screen-Shot-2017-02-27-at-3.22.49-PM-300x73.png 300w\" sizes=\"auto, (max-width: 413px) 85vw, 413px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Your devices will vary and you may see more of them based on how many peripherals you have connected.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Use the <\/span><i><span style=\"font-weight: 400;\">event-kbd <\/span><\/i><span style=\"font-weight: 400;\">and <\/span><i><span style=\"font-weight: 400;\">event-mouse<\/span><\/i><span style=\"font-weight: 400;\"> IDs and create a line for each to specify them in the script:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-object input-linux,id=kbd,evdev=\/dev\/input\/by-id\/usb-Matias_Ergo_Pro_Keyboard-event-kbd,grab_all=yes \\&lt;\/span&gt;<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-object input-linux,id=mouse,evdev=\/dev\/input\/by-id\/usb-Logitech_USB_Receiver-if02-event-mouse &lt;\/span&gt;<\/pre>\n<p><span style=\"font-weight: 400;\">Add one more line into the script to enable sound:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">-soundhw hda \\&lt;\/span&gt;<\/pre>\n<p><i><span style=\"font-weight: 400;\">**Note: This will allow you to reroute sound through the speakers connected to the host using a utility such as pulseaudio. Sound output can also be configured in Windows to output from the video card via a compatible hdmi or displayport cable.<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">By now, your script should look something like this:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#!\/bin\/bash\r\ncp \/usr\/share\/edk2.git\/ovmf-x64\/OVMF_VARS-pure-efi.fd \/tmp\/my_vars.fd\r\nqemu-system-x86_64 \\\r\n-enable-kvm \\\r\n-m 1024 \\\r\n-cpu host,kvm=off \\\r\n-vga none \\\r\n-soundhw hda \\\r\n-device vfio-pci,host=01:00.0,multifunction=on \\\r\n-device vfio-pci,host=01:00.1 \\\r\n-drive if=pflash,format=raw,readonly,file=\/usr\/share\/edk2.git\/ovmf-x64\/OVMF_CODE-pure-efi.fd \\\r\n-drive if=pflash,format=raw,file=\/tmp\/my_vars.fd \\\r\n-device virtio-scsi-pci,id=scsi \\\r\n-drive file=\/dev\/sda,id=disk,format=raw,if=none -device scsi-hd,drive=disk \\\r\n-drive file=\/home\/dcellular\/ISOs\/Windows10x64.iso,id=isocd,format=raw,if=none -device scsi-cd,drive=isocd \\\r\n-drive file=\/home\/dcellular\/downloads\/virtio-win.iso,id=virtiocd,if=none,format=raw -device ide-cd,bus=ide.1,drive=virtiocd\r\n-object input-linux,id=kbd,evdev=\/dev\/input\/by-id\/usb-Matias_Ergo_Pro_Keyboard-event-kbd,grab_all=yes \\\r\n-object input-linux,id=mouse,evdev=\/dev\/input\/by-id\/usb-Logitech_USB_Receiver-if02-event-mouse<\/pre>\n<p><span style=\"font-weight: 400;\">You are now ready to boot and install Windows. \u00a0Run your script from the command line and you should see the QEMU window pop-up on the desktop and the \u201c<\/span><i><span style=\"font-weight: 400;\">Press any key to continue\u2026\u201d<\/span><\/i><span style=\"font-weight: 400;\"> dialog on your second monitor or input. \u00a0Continue through the setup process until you reach the screen asking you to select the disk to install Windows onto. \u00a0Follow the prompt or select the option to install the necessary driver. \u00a0Navigate through the <\/span><i><span style=\"font-weight: 400;\">virtio<\/span><\/i><span style=\"font-weight: 400;\"> ISO to the <\/span><i><span style=\"font-weight: 400;\">virtscsi<\/span><\/i><span style=\"font-weight: 400;\"> folder and find the Windows 10 x64 driver. \u00a0This will allow you to see the disk drive that you want to install Windows to. \u00a0Follow through and finish the install. \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">At this point, you should have a fully functional installation of Windows so make sure to install all necessary updates before installing and drivers. \u00a0<\/span><\/p>\n<p><i><span style=\"font-weight: 400;\">**Note: I had issues originally trying to install the Nvidia drivers and was receiving errors about compatibility. \u00a0I eventually found out that Windows needed to be updated before they would install properly.<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">There are some additional configurations you may want to make to further optimize your VM, such as allocating additional RAM, specifying processor cores and threads, or using xrandr to control display output. \u00a0The following is how I have configured my script to start my VM:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#!\/bin\/bash\r\n\r\nxrandr --output HDMI1 --off\r\ncp \/usr\/share\/edk2.git\/ovmf-x64\/OVMF_VARS-pure-efi.fd \/tmp\/my_vars.fd\r\nqemu-system-x86_64 \\\r\n-enable-kvm \\\r\n-m 16384 \\\r\n-smp cores=4,threads=2 \\\r\n-cpu host,kvm=off \\\r\n-vga none \\\r\n-soundhw hda \\\r\n-device vfio-pci,host=01:00.0,multifunction=on \\\r\n-device vfio-pci,host=01:00.1 \\\r\n-drive if=pflash,format=raw,readonly,file=\/usr\/share\/edk2.git\/ovmf-x64\/OVMF_CODE-pure-efi.fd \\\r\n-drive if=pflash,format=raw,file=\/tmp\/my_vars.fd \\\r\n-device virtio-scsi-pci,id=scsi \\\r\n-drive file=\/dev\/sda,id=disk,format=raw,if=none -device scsi-hd,drive=disk \\\r\n-object input-linux,id=kbd,evdev=\/dev\/input\/by-id\/usb-Matias_Ergo_Pro_Keyboard-event-kbd,grab_all=yes \\\r\n-object input-linux,id=mouse,evdev=\/dev\/input\/by-id\/usb-Logitech_USB_Receiver-if02-event-mouse\r\nxrandr --output HDMI1 --mode &quot;3440x1440&quot; --rate 49.99 --right-of HDMI2<\/pre>\n<p><b>Additional resources and references:<\/b><\/p>\n<p><a href=\"https:\/\/bufferoverflow.io\/gpu-passthrough\/\"><span style=\"font-weight: 400;\">https:\/\/bufferoverflow.io\/gpu-passthrough\/<\/span><\/a><\/p>\n<p><a href=\"http:\/\/dominicm.com\/gpu-passthrough-qemu-arch-linux\/\"><span style=\"font-weight: 400;\">http:\/\/dominicm.com\/gpu-passthrough-qemu-arch-linux\/<\/span><\/a><\/p>\n<p><a href=\"https:\/\/wiki.archlinux.org\/index.php\/PCI_passthrough_via_OVMF\"><span style=\"font-weight: 400;\">https:\/\/wiki.archlinux.org\/index.php\/PCI_passthrough_via_OVMF<\/span><\/a><\/p>\n<p><a href=\"https:\/\/www.kraxel.org\/blog\/2016\/04\/linux-evdev-input-support-in-qemu-2-6\/\"><span style=\"font-weight: 400;\">https:\/\/www.kraxel.org\/blog\/2016\/04\/linux-evdev-input-support-in-qemu-2-6\/<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is intended to get you up and running with GPU passthrough using Arch Linux and Windows. There are a number of different guides out there including the Arch wiki; however, I found that some detail was lacking for beginners. I also wrote this for my own sanity in case I break something or &hellip; <a href=\"https:\/\/www.dcellular.net\/blog\/?p=6\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;GPU Pass-through with Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5,4],"tags":[],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-linux","category-vfio","category-windows"],"_links":{"self":[{"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6"}],"version-history":[{"count":41,"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":62,"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6\/revisions\/62"}],"wp:attachment":[{"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dcellular.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}