tech:cheatsheets:linux:kvm
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tech:cheatsheets:linux:kvm [2024/01/15 07:32] – removed - external edit (Unknown date) 127.0.0.1 | tech:cheatsheets:linux:kvm [2024/04/04 06:15] (current) – waldemar | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Linux KVM ====== | ||
| + | ===== How to install ===== | ||
| + | * https:// | ||
| + | |||
| + | ===== How to boot Dual Boot Windows Partition ===== | ||
| + | * https:// | ||
| + | * http:// | ||
| + | |||
| + | ==== Windows Partition Dual Mount ==== | ||
| + | * https:// | ||
| + | |||
| + | ==== Spoof BIOS & Mainboard to avoid re-activation ==== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ===== GPU Acceleration ===== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Due to NVIDIA GPUs needing a license to be able to use vGPU it's currently not really recommended to passthrough a vGPU but instead the whole GPU. The best approach for a desktop machine is to use the single GPU passthrough approach which stops the X server and starts up a pre-configured virtual machine. | ||
| + | |||
| + | ===== Seamless Windows ===== | ||
| + | * https:// | ||
| + | * Newer/More up-to-date: https:// | ||
| + | * https:// | ||
| + | * Snap does not work inside xpra (or so it seems). | ||
| + | * https:// | ||
| + | |||
| + | ===== Input Passthrough ===== | ||
| + | * https:// | ||
| + | |||
| + | ===== Hooks ===== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | ===== Nested Virtualization ===== | ||
| + | * https:// | ||
| + | |||
| + | ===== Drivers ===== | ||
| + | ==== NVIDIA ==== | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | === 535.129.03 === | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | ===== Sample Configurations ===== | ||
| + | ==== Old Notebook ==== | ||
| + | [[infrastructure: | ||
| + | <file xml win11.xml> | ||
| + | <domain type=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | <memory unit=" | ||
| + | < | ||
| + | < | ||
| + | <source type=" | ||
| + | <access mode=" | ||
| + | </ | ||
| + | <vcpu placement=" | ||
| + | <os firmware=" | ||
| + | <type arch=" | ||
| + | <boot dev=" | ||
| + | </os> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <hyperv mode=" | ||
| + | <relaxed state=" | ||
| + | <vapic state=" | ||
| + | < | ||
| + | </ | ||
| + | <vmport state=" | ||
| + | </ | ||
| + | <cpu mode=" | ||
| + | <clock offset=" | ||
| + | <timer name=" | ||
| + | <timer name=" | ||
| + | <timer name=" | ||
| + | <timer name=" | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <pm> | ||
| + | < | ||
| + | < | ||
| + | </pm> | ||
| + | < | ||
| + | < | ||
| + | <disk type=" | ||
| + | <driver name=" | ||
| + | <source dev="/ | ||
| + | <target dev=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <mac address=" | ||
| + | <source network=" | ||
| + | <model type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <channel type=" | ||
| + | <target type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <channel type=" | ||
| + | <target type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <input type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | <tpm model=" | ||
| + | <backend type=" | ||
| + | </ | ||
| + | < | ||
| + | <listen type=" | ||
| + | <image compression=" | ||
| + | <gl enable=" | ||
| + | </ | ||
| + | <sound model=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <audio id=" | ||
| + | < | ||
| + | <model type=" | ||
| + | < | ||
| + | </ | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== Desktop ==== | ||
| + | [[infrastructure: | ||
| + | <file xml win11-gpu.xml> | ||
| + | <domain xmlns: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | <memory unit=" | ||
| + | < | ||
| + | < | ||
| + | <source type=" | ||
| + | <access mode=" | ||
| + | </ | ||
| + | <vcpu placement=" | ||
| + | <os firmware=" | ||
| + | <type arch=" | ||
| + | < | ||
| + | </os> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <hyperv mode=" | ||
| + | <relaxed state=" | ||
| + | <vapic state=" | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | <kvm> | ||
| + | <hidden state=" | ||
| + | </ | ||
| + | <vmport state=" | ||
| + | </ | ||
| + | <cpu mode=" | ||
| + | < | ||
| + | <feature policy=" | ||
| + | </ | ||
| + | <clock offset=" | ||
| + | <timer name=" | ||
| + | <timer name=" | ||
| + | <timer name=" | ||
| + | <timer name=" | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <pm> | ||
| + | < | ||
| + | < | ||
| + | </pm> | ||
| + | < | ||
| + | < | ||
| + | <disk type=" | ||
| + | <driver name=" | ||
| + | <source dev="/ | ||
| + | <target dev=" | ||
| + | <boot order=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <target chassis=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <model name=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <mac address=" | ||
| + | <source network=" | ||
| + | <model type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <channel type=" | ||
| + | <target type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <input type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <input type=" | ||
| + | <address type=" | ||
| + | </ | ||
| + | <input type=" | ||
| + | <input type=" | ||
| + | <tpm model=" | ||
| + | <backend type=" | ||
| + | </ | ||
| + | <audio id=" | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <address domain=" | ||
| + | </ | ||
| + | <rom file="/ | ||
| + | <address type=" | ||
| + | </ | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <address domain=" | ||
| + | </ | ||
| + | <rom file="/ | ||
| + | <address type=" | ||
| + | </ | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <address domain=" | ||
| + | </ | ||
| + | <rom file="/ | ||
| + | <address type=" | ||
| + | </ | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <address domain=" | ||
| + | </ | ||
| + | <rom file="/ | ||
| + | <address type=" | ||
| + | </ | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <vendor id=" | ||
| + | <product id=" | ||
| + | </ | ||
| + | <address type=" | ||
| + | </ | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <vendor id=" | ||
| + | <product id=" | ||
| + | </ | ||
| + | <address type=" | ||
| + | </ | ||
| + | <hostdev mode=" | ||
| + | < | ||
| + | <vendor id=" | ||
| + | <product id=" | ||
| + | </ | ||
| + | <address type=" | ||
| + | </ | ||
| + | < | ||
| + | <address type=" | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <file bash / | ||
| + | #!/bin/bash | ||
| + | |||
| + | GUEST_NAME=" | ||
| + | HOOK_NAME=" | ||
| + | STATE_NAME=" | ||
| + | MISC=" | ||
| + | |||
| + | BASEDIR=" | ||
| + | |||
| + | HOOKPATH=" | ||
| + | set -e # If a script exits with an error, we should as well. | ||
| + | |||
| + | echo "QEMU hook: $GUEST_NAME/ | ||
| + | |||
| + | if [ -f " | ||
| + | eval \"" | ||
| + | elif [ -d " | ||
| + | while read file; do | ||
| + | eval \"" | ||
| + | done <<< | ||
| + | fi | ||
| + | </ | ||
| + | |||
| + | <file bash / | ||
| + | #!/bin/bash | ||
| + | set -x | ||
| + | |||
| + | # Stop display manager | ||
| + | systemctl stop display-manager | ||
| + | # systemctl --user -M YOUR_USERNAME@ stop plasma* | ||
| + | |||
| + | # Unbind VTconsoles: might not be needed | ||
| + | echo 0 > / | ||
| + | echo 0 > / | ||
| + | |||
| + | # Unbind EFI Framebuffer | ||
| + | echo efi-framebuffer.0 > / | ||
| + | |||
| + | # Unload NVIDIA kernel modules | ||
| + | modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia | ||
| + | |||
| + | # Unload AMD kernel module | ||
| + | # modprobe -r amdgpu | ||
| + | |||
| + | # Detach GPU devices from host | ||
| + | # Use your GPU and HDMI Audio PCI host device | ||
| + | virsh nodedev-detach pci_0000_01_00_0 | ||
| + | virsh nodedev-detach pci_0000_01_00_1 | ||
| + | virsh nodedev-detach pci_0000_01_00_2 | ||
| + | virsh nodedev-detach pci_0000_01_00_3 | ||
| + | |||
| + | # Load vfio module | ||
| + | modprobe vfio-pci | ||
| + | </ | ||
| + | |||
| + | <file bash / | ||
| + | #!/bin/bash | ||
| + | set -x | ||
| + | |||
| + | # Attach GPU devices to host | ||
| + | # Use your GPU and HDMI Audio PCI host device | ||
| + | virsh nodedev-reattach pci_0000_01_00_0 | ||
| + | virsh nodedev-reattach pci_0000_01_00_1 | ||
| + | virsh nodedev-reattach pci_0000_01_00_2 | ||
| + | virsh nodedev-reattach pci_0000_01_00_3 | ||
| + | |||
| + | # Unload vfio module | ||
| + | modprobe -r vfio-pci | ||
| + | |||
| + | # Load AMD kernel module | ||
| + | #modprobe amdgpu | ||
| + | |||
| + | # Rebind framebuffer to host | ||
| + | echo " | ||
| + | |||
| + | # Load NVIDIA kernel modules | ||
| + | modprobe nvidia_drm | ||
| + | modprobe nvidia_modeset | ||
| + | modprobe nvidia_uvm | ||
| + | modprobe nvidia | ||
| + | |||
| + | # Bind VTconsoles: might not be needed | ||
| + | echo 1 > / | ||
| + | echo 1 > / | ||
| + | |||
| + | # Restart Display Manager | ||
| + | systemctl start display-manager | ||
| + | </ | ||