Skip to content

Useful guides from my other github repo.

Nicholas edited this page May 11, 2024 · 17 revisions

Creating your rom

To create a rom you would need to download the following tools in a windows machine (dualboot), if you are dualbooting from windows be sure to create a backup with cloning software i personally use acronis but you can use clonezilla if that's a thing; just be sure you have an addtional hard drive around and that drive has enough space for all partitions.

  1. Gpu-Z

Download GPU-Z here

click on what has been circled and click write to file, it will save it as a rom; be sure to save it to where arch has access to it otherwise you will have to create a mount point. For AMD users the process should be the same.

SavingBios

Viewing VBios from arch

To view the vbios from arch you will simply need to install nvidia-settings for nvidia users, then on the GPU tab you will be able to view the vbios.

FahGRWf

then do some google-fu site:techpowerup.com <vbios goes here>

Example site:techpowerup.com 86.04.99.00.06

AMD Users

You would have to try this tool, this does indeed work. just simply follow the instructions on how to save the vbios in linux, do not write.

Patching your ROM

NOTICE FOR APT (ubuntu/debian) Users Bless crashes and is NOT useable, for clearity sake you can just use hexed.it

  1. Go to this download link and download the ROM of your exact GPU (or do some google-fu).
  1. Once you have your rom downloaded, type in sudo pacman -S bless to download the hex editor to patch your rom.

  2. Open your ROM with the Bless hex editor, as a Sith once said: "This is where the fun begins."

  3. Press CTRL + F to search, and search for "VIDEO" as text.

  1. Then, delete everything before the "U.s" or "U.y" or whatever, and save your ROM as something simple (i.e: patch.rom).
  1. Once your ROM has been patched, open your terminal in the folder which you have your ROM saved in, and type in

    sudo mkdir /var/lib/libvirt/vbios/ && sudo mv <RENAME TO YOUR ROM>.rom /var/lib/libvirt/vbios
    

For Ubuntu/Debian Based it should be placed inside /usr/share/vgabios/, the config libvirt script for Ubuntu should create the dir for you if it doesn't exist, just place it there.

and make sure to rename to what you named your ROM.

  1. Then your ROM should be all patched and good to go!

GPU

  1. Add every PCI device which has to do with your graphics card to the VM, use the patched rom in the XML file.

  2. Edit the XML of each passed through PCI device that has to do with your GPU and add the line
    <rom file="/var/lib/libvirt/vbios/<ROMFILE>.rom"/>.
    Make sure to rename ROMFILE to what you named your ROM.

  1. Boot inside the VM, find the GPU with windows update as that shouldn't take long then power it off.

  2. Pass through your audio device and your USB controller, do this after windows finds your GPU with windows update.

  1. usb redirect any usb devices that are having issues, i would redirect your headset for headset users and the mouse. add hardware > usb host device > the desired device

  2. USB redirect with evdev

archwiki

USB Host Redirection example

  1. Lastly, remove every spice/qxl device from your virtual machine Note: Only do this after getting the proper drivers from windows update, otherwise your GPU will not work inside the VM.
  1. If you are using an NVIDIA graphics card, add these lines to your XML overview. Also this could be used to hide your VM so I would go ahead an add anyway, be sure to turn ON hyper-v in windows features.

Features:

   </os>
   <features>
   <acpi/>
   <apic/>
   <hyperv mode="custom">
   <relaxed state="on"/>
   <vapic state="on"/>
   <spinlocks state="on" retries="8191"/>
   <vpindex state="on"/>
   <runtime state="on"/>
   <synic state="on"/>
   <reset state="on"/>
   </hyperv>
   <kvm>
   <hidden state="on"/>
   </kvm>
   <vmport state="off"/>
   <ioapic driver="kvm"/>
   </features>

To make sure virtual machine is not found in the VM set feature hypervisor off like so under CPU:

   <cpu mode="host-passthrough" check="none" migratable="on">
   <topology sockets="1" dies="1" cores="2" threads="2"/>
   <feature policy="disable" name="hypervisor"/>
   </cpu>

Be aware that you'd have to edit the amount of core/socks/threads to reflect on the amount of vcpu placments like so

   <vcpu placement="static">4</vcpu>

and that <feature policy="disable" name="hypervisor"/> hides the hypervisor.

clock settings:

   <clock offset="localtime">
   <timer name="rtc" tickpolicy="catchup"/>
   <timer name="pit" tickpolicy="delay"/>
   <timer name="hpet" present="no"/>
   <timer name="hypervclock" present="yes"/>
   </clock>

for clock offset, you can either use windows localtime or linux UTC; if you're having issues with localtime set the
offset of the clock to UTC and vise versa. more info found Here. If you wanted to hide virtualization inside task manager, which wouldn't hurt keep this code as is or remove: <feature policy="disable" name="hypervisor"/> Under <CPU>

and for the sake of it, here's a windows 11 example, do copy paste if you want and feel free to use.

I want to change my smbios.

<sysinfo type="smbios">
<bios>
<entry name="vendor">Fake BIOS Vendor</entry>
<entry name="version">Fake BIOS Version</entry>
</bios>
<system>
<entry name="manufacturer">Fake Manufacturer</entry>
<entry name="product">Fake Product</entry>
</system>
</sysinfo>
<!-- other XML nodes -->
<os>
<!-- other XML nodes -->
<smbios mode="sysinfo"/>
</os>

More info can be found out on this; here.

notice the sata connections?

These would be used for a Hard Drive pass though, basically handing off your hard drive to the vm. the process is the same as usb-host, just add the hard drive by selecting storage than manage and the path, usually it starts with /dev/sxx; a good example is /dev/sdc you can find info about this using sudo fdisk -l, I would be careful about handing off hard drives this way and to not edit the xml docs, just boot up virt-manager and remove the hard drive, DO NOT DELETE WHEN ASKED; just remove the storage device.

For people having issues with games such as red dead 2 Enter this value here inside the XML document for your new/current VM:

The first part which is the domain under metadata

<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">

Specifically add in this part;

xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0"

The Emulator Path, edit accordingly.

<pm>
<suspend-to-mem enabled="no"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/path/to/qemu-system-x86_64-pass</emulator>

And the QEMU Command Line

<qemu:commandline>
<qemu:arg value="-smbios"/>
<qemu:arg value="type=2,manufacturer=ASRock,product=X470 Taichi,version=AM4,serial=S4M88119"/>
<qemu:arg value="-smbios"/>
<qemu:arg value="type=4,manufacturer=AMD,version=1000"/>
<qemu:arg value="-smbios"/>
<qemu:arg value="type=17,manufacturer=Micron"/>
</qemu:commandline>

Also do not forgot to set your smbios mode to host like so if all else fails:

<smbios mode="host"/>
</os>

You can use other manufacturers such as gigabyte, asus, etc; if you want to reflect on your physical motherboard be sure to look at the specs at the website of the manufacturer, usually found at the motherboards website (usually it's the CPU and stuff) after pulling up

sudo dmidecode -t 2 

and

lspci

for the semiconductor info and serial number, cannot find the serial number? Then it shouldn't matter much and you can use the value provided or open her up (welcome to the real world) and look for a sticker.

You also need to patch the binary of qemu-system-x86_64, you can cp the file inside a new dir from /usr/bin/qemu-system-x86_64 to a new file such as /home/"username"/patch/qemu/qemu-system-x86_64, or you may keep it inside it's current directory with a new name such as the one listed above for safe keeping; be sure to run sudo.

after all is done and you dual-boot

If you want use gparted to delete the ntfs volume, recovery volume; anything microsoft (except the efi-partitons, unless if that's mounted somewhere else in linux, don't touch the linux partitions), when finished delete the bios options to boot from windows with efibootmgr; be sure to resize the disk accordingly.

view entries with efibootmgr:

efibootmgr -v

then delete the entry with

efibootmgr -b # -B #

Bonus Scream driver

Scream driver passthough with arch linux. good for those who don't want to use USB.

Install the scream driver, for windows 11/EFI you'll need to set the date to 2022 or earlier.

for the driver to work you'll need to install the scream audio receiver (you won't be able to use a mic with this!)

Place this inside your XML:

  <shmem name='scream-ivshmem'>
    <model type='ivshmem-plain'/>
    <size unit='M'>2</size>
  </shmem>

Registry editing, you'll need to edit this value.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CI\Policy]
"UpgradedSystem"=dword:00000001

Then you should be all set.

Passing though other devices VIA OVMF (USB)

https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Passing_keyboard/mouse_via_Evdev

For your mouse, you can change ctrl+ctrl for grabbing the mouse and keyboard or leave it as it. basically if you were to press both ctrl+ctrl you'd have control of your mouse and keyboard back to your host system again.

<input type='evdev'>
      <source dev='/dev/input/by-id/MOUSE_NAME'/>
    </input>
    <input type='evdev'>
      <source dev='/dev/input/by-id/KEYBOARD_NAME' grab='all' repeat='on' grabToggle='ctrl-ctrl'/>
    </input>

Your virtual mouse and keyboard; place this inside the XML doc for the VM.

            <input type='mouse' bus='virtio'/>
	<input type='keyboard' bus='virtio'/>

The device input by-id has to be an event, example:

  /dev/input/by-id/usb-Corsair_Corsair_Gaming_K65_LUX_RGB_Keyboard_0B032027AEBD15015626BFDEF5001945-if01-event-kbd

 /dev/input/by-id/usb-SteelSeries_SteelSeries_Rival_100_Dell_China-if01-event-mouse