ASUS tuf gaming f16 laptop

I've bought asus tuf gaming f16 laptop with no OS. Here I will note process of setup. Basically I want to install smallest Linux possible like Arch then install virtual machines above. I want have a clear stable host system. I need enable Mac os support and GPU support for virtual machines.

 

asus notebook with unix and SO|lower


LAPTOP ASUS TUF F16

1. Only High Sierra MAC OS supports NVIDIA GPU.

3. QEMU/KVM/libvirt kernel is needed

 

BIOS

1. To enter BIOS press F2.

2. Option Enable VMD Controller (Volume Management Device) disable for linux.

3. Intel virtualization technology and VT-d should be enabled in BIOS.

 

Installation

1. I choose Debian netinst. I chose advanced graphical expert mode installation.

2. It uses 705 Mb without desktop. To see processes $ ps aux --sort=-%mem | head -20

3. What processes I see:

  • /usr/lib/systemd/systemd-journald VSZ 42812 RSS 16940 // You could limit max journal size with its conf file.
  • /sbin/init VSZ 23884 RSS 14876
  • /usr/lib/systemd/systemd-timesyncd VSZ 91812 RSS 8294 // To disable $ sudo systemctl disable --now systemd-timesyncd
  • /usr/libexec/bluetooth/bluetoothd VSZ 12496 RSS 6580. 
  • (sd-pam) VSZ 24616 RSS 3848.
  • /usr/sbin/cron -f VSZ 6856 RSS 2856 and /usr/sbin/anacron // Some scheduler not very important
  • /usr/bin/mpris-proxy VSZ 7224 RSS 3656 // For music $ systemctl --user disable mpris-proxy
  • /usr/sbin/wpa_supplicant -u -s -o DIR=/run/wpa_supplicant GROUP=netdev // It is for wifi
  • /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only // fundamental
  • Kernel threads in []: [kthreadd], [pool_workqueue_release], [kworker/R-kvfree_rcu_reclaim], [kworker/R-rcu_gp], [kworker/R-sync_wq], [kworker/R-slub_flushwq], [kworker/R-netns], [kworker/0:0-events_freezable], [kworker/0:0H-events_highpri], [kworker/0:1-events], [kworker/u64:0-events_unbound], [kworker/R-mm_percpu_wq],[rcu_tasks_kthread]
  • /usr/libexec/at-spi-bus-launcher Not essential GUI interraction abilities like screen readers. // $ sudo apt remove --purge at-spi2-core

4. Kernel spends most of memory to check use $ free -h and $ cat /proc/meminfo | grep -E "MemTotal|MemFree|Buffers|Cached|Slab|SReclaimable|SUnreclaim|KernelStack|PageTables|VmallocUsed"

 

 

 

 

 

Problem. Laptop doesn't wake up after suspend

BIOS

1. Fastboot disable // doesn't helped

2. ErP disable. // Helped only for hibernate

 

GUI installation

1. I need minimal GUI only to access virtual machine's GUI.

1.1. xinit for startup

1.2. xserver-xorg-core Handles display rendering, input devices (keyboard/mouse), and window management.

1.3. openbox window management

1.4

sudo apt install -y \

 xinit \               # Essential: Manual GUI startup

 xserver-xorg-core \   # Essential: Core graphics stack

 openbox               # Lightweight window manager (replace LXDE)

1.5 Network manager $ sudo apt install network-manager to setup wifi connection without disrupting br0 ethernet setup.

1.5.1 Edit $ sudo nano /etc/NetworkManager/NetworkManager.conf

[main]

plugins=ifupdown,keyfile

[ifupdown]

managed=false

[keyfile]

# Bloqueia TODAS as conexões cabeadas e pontes por tipo, e gerencia apenas a sua placa wi-fi

unmanaged-devices=type:ethernet;type:bridge;exception:interface-name:wlp3s0

1.5.2. Comment out lines started with iface wlp $ sudo nano /etc/NetworkManager/NetworkManager.conf

1.5.3. To start $ sudo nmtui and connect 

1.5.4. Delete default br0 gateway

1.5.5. If you want add command to openbox to /etc/xdg/openbox/menu.xml

 

 

2. What packages $ apt list --installed  I have:

adduser/stable, adwaita-icon-theme, anacron, apparmor, apt-listchanges, apt-utils, apt, at-spi2-common, base-files, base-passwd, bash-compleation, bash, bind9-dnsutils, bind9-host, bind9-libs, bsdextrautils, bsdutils, busybox, bzip2, ca-certificates, console-setup-linux, console-setup, coreutils, cpio, cron-daemon-common, cron, dash, dbus-bin, dbus-daemon, dbus-session-bus-common, dbus-system-bus-common, dbus-user-session, dbus, dconf-gsettings-backend, dconf-service, debconf-i18n, debconf, debian-archive-keyring, debian-faq, debian-utils, dhcpcd-base, dictionaries-common, diffutils, distro-info-data, dmidecode, dmsetup, doc-debian, dpkg, dracut-install, e2fsprongs, efibootmgr, emacsen-common, fdisk, file, findutils, firmware-intel-graphics, firmware-nvidia-graphics, firmware-realtec, firmware-sof-signed, fontconfig-config, fontconfig, fonts-dejavu-core, fonts-dejavu-mono, fonts-droid-fallback, fonts-noto-mono, fonts-urw-base35, gcc-14-base, gettext-base, grep, groff-base, grub-common, grub-efi-amd64-bin, grub-efi-amd64-signed, grub-efi-amd64-unsigned, grub-efi-amd64, grub2-common, gtk-update-icon-cache, gzip, hicolor-icon-theme, hostname, iamerican, ibritish, ienglish-common, ifupdown, inetutils-telnet, init-system-helpers, init, initframfs-tools-bin, initframfs-tools-core, initframfs-tools, installation-report, intel-microcode,  iproute2, iputils-ping, iso-code, ispell, iucode-tool, iw, kbd, keyboard-configuration, klibc-utils, kmod, krb5-locales, laptop-detect, less, linux-base, linux-image-6.12.73+deb13-amd64, linux-image-6.12.73+deb13+1-amd64, linux-image-amd, linux-sysctl-defaults, locales, login.defs, login, logrotate, logsave, lsb-release, lsof, man-db, manpages, mawk, media-types, mesa-libgallium, mesa-vulkan-drivers, mokutil, mount, nano, ncurses-base, ncurses-bin, ncurses-term, netcat-traditional, nftables, obconf, openbox, openssh-client, openssl-provider-legacy, openssl, os-prober, passwd, pci.ids, pcutils, perl-base, perl-modules-5.40, perl, poppler-data, powertop, procps, publicsuffix, python-apt-common, python3-apt, python3-certifi, python3-chardet, python3-charset-normalizer, python3-debconf, python3-debian, python3-debianbts, python3-idna, python3-minimal, python3-reportbug, python3-requests, python3-urllib3, python3.13-minimal, python3.13, python3, readline-common,reportbug, scrot, sed, sensible-utils, shared-mime-info, shim-helpers-amd64-signed, shim-signed-common, shim-signed, shim-unsigned, sqv, sudo, systemd-sysv, systemd-timesyncd, systemd,sysvinit-utils, tar, task-english, task-laptop, tasksel-data, tasksel, traceroute, tzdata, ucf, udev, usbutils,, util-linux-extra, util-linux-locales, util-linux, vim-common, vim-tiny, wamerican, wget, whiptail, wireless-regdb, wireless-tools,wpasupplicant, wtmpdb, x11-common, x11-xkb-utils, xauth, xcvt, xdg-user-dirs, xfonts-base, xfonts-encodings, xfonts-utils, xinit, xkb-data, xserver-common, xserver-xorg-core, xserver-xorg-input-all, xserver-xorg-input-lininput, xserver-xorg-input-wacom, xserver-xorg-legacy, xserver-xorg-video-all, xserver-xorg-video-amdgpu, xserver-xorg-video-ati, xserver-xorg-video-fbdev, xserver-xorg-video-intel, xserver-xorg-video-nouveau, xserver-xorg-video-qxl, xserver-xorg-video-radeon, xserver-xorg-videovesa, xserver-xorg-video-vmware, xserver-xorg, xz-utils, zlib1g, zstd.

 

CREATING VIRTUAL MACHINES

GPU PASSTHROUGH

1. The laptop's integrated Intel GPU handles host display, while dedicated RTX GPU is passed through. You bind DGPU to vfio VM driver.

HOST PREPARATION

GRUB

1. Enable IOMMU in Kernel. Needed for GPU passthrough

1.1. $ sudo nano /etc/default/grub Change variable GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt"

1.1.2 Update GRUB and reboot

$ sudo update-grub

$ sudo reboot

1.2. Verify IOMMU is Active

$ dmesg | grep -i iommu  # Expected output: "Intel-IOMMU: enabled" or "DMAR: IOMMU enabled"

1.3. Check IOMMU groups. To be sure GPU doesn't share same group with USB, PCI or etc. Run bash script:

for g in /sys/kernel/iommu_groups/*; do

    echo "=== IOMMU Group ${g##*/} ===";

    for d in "$g"/devices/*; do

        lspci -nns "${d##*/}"

    done

    echo

done | grep -A20 -iE 'nvidia|vga|3d'

 

1.4. $ lspci -nn | grep -i 'VGA\|Audio'

1.7. Ensures VFIO loads early in boot, before NVIDIA drivers $ sudo nano /etc/initramfs-tools/modules add to the end:

vfio

vfio_iommu_type1

vfio_pci

vfio_virqfd

 

1.4. Temporary attach to vfio-pci configuration if RTX GPU is not binded to any driver at start. $ sudo modprobe vfio-pci then validate $ lsmod | grep vfio

1.5. Unbind NVIDIA audio from host $ echo 0000:01:00.1 | sudo tee /sys/bus/pci/devices/0000:01:00.1/driver/unbind validate $ lspci -nnk -s 01:00.1

1.6. Register IDs with vfio-pci:

$ echo 10de 2d58 | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id

$ echo 10de 22eb | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id

1.7. Bind devices to VFIO 

$ echo 0000:01:00.0 | sudo tee /sys/bus/pci/drivers/vfio-pci/bind

$ echo 0000:01:00.1 | sudo tee /sys/bus/pci/drivers/vfio-pci/bind

1.7.1. Validate $ lspci -nnk

BACK TO NORMAL

1.8. Just reboot or:

1.8.1 Unbind from VFIO

echo 0000:01:00.0 | sudo tee /sys/bus/pci/drivers/vfio-pci/unbind

echo 0000:01:00.1 | sudo tee /sys/bus/pci/drivers/vfio-pci/unbind

1.8.2. Rebind audio

sudo modprobe snd_hda_intel

echo 0000:01:00.1 | sudo tee /sys/bus/pci/drivers/snd_hda_intel/bind

 

PERMANENT DRIVER CONFIG.

1.5.  Create VFIO config bind the devices to vfio-pci ("hide" the GPU from the NVIDIA/Nouveau drivers so vfio-pci can grab it) $ sudo nano /etc/modprobe.d/vfio.conf Add:

options vfio-pci ids=10de:2d58,10de:22eb (substitute with your ids have)

softdep nvidia pre: vfio-pci

softdep nouveau pre: vfio-pci

1.5.1. $echo "vfio-pci" | $ sudo tee /etc/modules-load.d/vfio.conf

1.5.2. Load the modules at boot $ sudo nano /etc/modules add:

vfio

vfio_iommu_type1

vfio_pci

 

1.6. It could prevent fallback on reboot!!! Blacklist the Nvidia driver (optional but clean) 

$ echo "blacklist nvidia" | sudo tee /etc/modprobe.d/blacklist-nvidia.conf

$ echo "blacklist nouveau" | sudo tee -a /etc/modprobe.d/blacklist-nvidia.conf

 

1.6. $ sudo update-initramfs -u && sudo reboot

 

Evaluate

2. $ lspci -nnk -s 01:00.0 // You should see Kernel driver in use: vfio-pci.

Expected

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation ... [10de:2d58]

    Kernel driver in use: vfio-pci

    Kernel modules: nouveau

2.1 $ lsmod | grep vfio // Check VFIO modules

Expected:

vfio_pci               16384  0

vfio_iommu_type1       28672  0

vfio                   32768  2 vfio_pci,vfio_iommu_type1

3. $ ls -lh /boot/initrd.img-$(uname -r) // Expected: File updated with current timestamp

3. Inside Windows, Device Manager shows the RTX 5070 with driver installed (no yellow exclamation).

 

Fallback

3. Returning the RTX to the host // delete or comment out /etc/modprobe.d/vfio.conf and /etc/modules-load.d/vfio.conf 

4. Remove Nvidia blacklist if you added it /etc/modprobe.d/blacklist-nvidia.conf.

5. $ sudo update-initramfs -u

 

1.7. Script

#!/bin/bash

# Usage: ./gpu_passthrough.sh [start|stop]

case "$1" in

  start)

    # Unbind from host, bind to VFIO

    echo "10de:1f06 10de:10f1" > /sys/bus/pci/drivers_probe

    modprobe vfio-pci

    ;;

  stop)

    # Revert to host drivers

    echo 1 > /sys/bus/pci/devices/0000:01:00.0/remove

    echo 1 > /sys/bus/pci/rescan

    modprobe nvidia

    ;;

esac

 

VM WINDOWS 10 SETUP<features>

2.0. Add Hardware → PCI Host Device -> your GPU 01:00.0 (RTX 5070). Then Add Hardware → PCI Host Device -> 01:00.1 (NVIDIA Audio).

2. Add the RTX as a PCI device and hide the hypervisor to avoid Nvidia Error 43. Virt-manager -> Details → Overview → XML // That is basically spoofing and making VM looks like a real machine.

<cpu mode='host-passthrough' check='none'>

<feature policy='require' name='topoext'/> // Maximum CPU speed and anti-cheat compatibility.

<topology sockets='1' dies='1' cores='4' threads='2'/>

<feature policy='require' name='vmx'/>

<feature policy='disable' name='hypervisor'/>

</cpu>

 

2.1.1. Check XML is valid $ virsh dumpxml win10 > /dev/null && echo "XML Valid" || echo "XML Invalid"

2.1.2. Verify GPU passthrough config $ virsh dumpxml win10 | grep -A5 hostdev

2.9. Delete excesive xml tags. Worlkng configuration is:

<features>

  <acpi/>

  <apic/>

  <hyperv>

    <relaxed state='on'/>

    <vapic state='on'/>

    <spinlocks state='on' retries='8191'/>

  </hyperv>

  <kvm>

    <hidden state='on'/>

  </kvm>

</features>

<cpu mode='host-passthrough' check='none'/>

 

3. Delete Nvidia drivers with DDU.

3.1. Reinstall Nvidia driver // works

 

Looking Glass

0. GPU won't work for display. It just rendering to HDMI out. But CUDA will work.

0.1. Support forum forum.level1techs.com/c/software/lookingglass/142

1. Prerequsites $ sudo apt install git cmake make gcc g++ pkg-config libegl1-mesa-dev libgl1-mesa-dev libgles2-mesa-dev libx11-dev libxfixes-dev libxi-dev libxinerama-dev libxss-dev libxcursor-dev libxpresent-dev libspice-protocol-dev libfontconfig1-dev nettle-dev libwayland-dev libxkbcommon-dev libpipewire-0.3-dev libpulse-dev libsamplerate0-dev

Essential

pkg-config - Helps find installed libraries

libegl1-mesa-dev - EGL (modern rendering backend)

libgl1-mesa-dev - OpenGL

libgles2-mesa-dev - OpenGL ES (used internally sometimes)

WINDOWING X11

libx11-dev - Base X11

libxfixes-dev - Cursor handling

libxi-dev - Input (mouse/keyboard)

libxinerama-dev - Multi-monitor

libxss-dev - Screen saver / idle

libxcursor-dev - Cursor rendering

libxpresent-dev - Smooth frame presentation

libspice-protocol-dev - SPICE protocol headers

libfontconfig1-dev - fonts

nettle-dev - crypto backend

libwayland-dev - Wayland protocol

libxkbcommon-dev - keyboard input handling (keymaps, layouts, key translation)

libsamplerate0-dev - audio

 

1.1 Build Looking Glass on Debian host

$ git clone --recursive --branch B7 https://github.com/gnif/LookingGlass.git

$ cd LookingGlass

$ mkdir client/build

$ cd client/build

$ cmake ../   or $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=OFF ..

$ make -j $(nproc)

$ sudo make install

1.1.1. $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local .. produce error:

CMake Error at /home/user/LookingGlass/cmake/CheckSubmodule.cmake:9 (message): Submodules are not initialized. Run
git submodules update --init --recursive

Call stack (most recent call first):
CMakeLists.txt:18 (include)

From the LookingGlass repository root try $ git submodule update --init --recursive

 

1.1 Validation

$ command -v looking-glass-client

$ ldd /usr/local/bin/looking-glass-client | grep 'not found' || true

$ looking-glass-client --version

2. How to delete Looking Glass client to install other version.

cd ~/LookingGlass/client/build

sudo make uninstall

sudo rm -f /usr/local/bin/looking-glass-client

rm -rf ~/LookingGlass

 

 

Configure Shared Memory

2.1. Create a configuration file for the memory device $ sudo nano /etc/tmpfiles.d/looking-glass.conf Paste this line (This reserves 32MB, enough for 1080p. For 4K, use 128MB):

f /dev/shm/looking-glass 0660 libvirt-qemu kvm -   

0660 rw-rw---- Owner+group read/write, others none (security)

libvirt-qemu Owner QEMU process runs as this user // Put this in it, replacing YOURUSER with the Linux account that will run looking-glass-client

kvm Group VM needs group access to shared memory

- No expiry Persistent until reboot

 

2.1.1. Option B: Manual Method (If tmpfiles fails)

# Create file manually

$ sudo touch /dev/shm/looking-glass

$ sudo chown libvirt-qemu:kvm /dev/shm/looking-glass

$ sudo chmod 660 /dev/shm/looking-glass

# Make persistent across reboots (add to /etc/rc.local or systemd service)

 

2.2. Apply the configuration immediately: $ sudo systemd-tmpfiles --create /etc/tmpfiles.d/looking-glass.conf // Validation $ ls -l /dev/shm/looking-glass You should see the file with owner libvirt-qemu and group kvm

2.3. sudo systemd-tmpfiles --create

 

 

GUEST VM LOOKING GLASS SETUP

2.4. Dump $ virsh dumpxml win10 > ~/win10-backup-before-looking-glass.xml

2.1. Add the IVSHMEM Driver Support (also in <devices>): Ensure you have a <channel> for virtio-serial as mentioned in your guide. This allows the host and guest to sync mouse and keyboard movements.

2.2. Add the Shared Memory Device (inside the XML <devices> section):

<devices>

<shmem name='looking-glass'>  <!--name='looking-glass' Must match /dev/shm/looking-glass Links to host shared memory -->

<model type='ivshmem-plain'/>

<size unit='M'>32</size> <!-- 128M for 4K size unit='M'>64 64MB Supports up to ~1440p@60Hz; use 128 for 4K -->

<!-- address type='pci' domain='0x0000' bus='0x10' slot='0x01' function='0x0'/ --> <!-- bus='0x10' Unique PCI bus Avoids conflicts with other devices slot='0x01' Unique slot Must not conflict with GPU (01:00.x)  --> // not essential

</shmem>

</devices>

  - name: Must match host-side file (/dev/shm/looking-glass)

  - size: Must match host allocation (64MB recommended)

  - model: ivshmem-plain (standard protocol)

4.0. IVSHMEM Driver: Download the virtio-win ISO fedorapeople.org/groups/virt/virtio-win/direct-downloads/upstream-virtio/. In Windows Device Manager, you will see a "PCI Standard RAM Controller." Right-click > Update Driver > Browse my computer > Point to the IVSHMEM folder virtio-win-0.1.xxx\ivshmem\w10\amd64 on the VirtIO ISO. Install Looking Glass Host Service looking-glass.io/downloads Run as Admin. Validation: Service appears in Task Manager → Services as "Looking Glass Host Service".

Actually we just need to start installer as admin and driver will be installed automatically. // Validation: Device should now show: "IVSHMEM Device"

 

2.3. KVMFR approach is newer and more effective. Less CPU usage. // Plan B

2.3. VirtIO-Serial Channel (The "Input Pipe") Sync mouse/keyboard between host and VM

<!-- Virtio-Serial for SPICE Mouse -->

<devices>

<channel type='spicevmc'> <!-- SPICE Channel for Looking Glass Input Sync type='spicevmc' -->

<target type='virtio' name='com.redhat.spice.0'/>  <!--  - name: com.redhat.spice.0 (standard SPICE agent name) -->

<address type='virtio-serial' controller='0' bus='0' port='1'/>  <!--   - controller: Must match virtio-serial controller index, port='1' Unique port Avoids conflicts with other virtio-serial devices -->

</channel>

</devices>

3. Install SPICE Agent from spice-space.org/download/windows/spice-guest-tools/  // Validate via Task Manager → "SPICE Guest Agent" or spice-vdagent

3.1. Mouse is not capturing. 

In xml video model type change to vga

input type='tablet'  - remove

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

$ looking-glass-client -m KEY_ESC -с none // working when you press the ESC key mouse is binding

3.2. Resolution is very low. How to improve.

3.2.1. Increase in xml shmem to 128.

3.2.2. After increasing IVSHMEM size in VM xml VM failed to start with message virDomainCreate() failed Error starting domain internal error QEMU unexpectedly closed the monitor vm=win11 qemu-system-x86_64 shmmem-shmem0 backing store is to small for size option 0x8000000 plus offset option 0x0 

3.2.3. Try to delete old file and create new one.

$ sudo rm -rf /dev/shm/looking-glass

$ sudo chmod 666 /dev/shm/looking-glass

3.3. I bought dummy plug. Now I when I start looking-glass-client window starts then shuts with message in console Format: FRAME_TYPE_BGRA 3840x2160 stride:3840 pitch:15360 rotation:0 hdr:0 pq:0

$ looking-glass-client -m KEY_ESC -s -g opengl

3.4. Doesn't capture mouse or keyboard. // Do not disable SPICE server on VM and do not use -s parameter.

 

 

2.4. Disable the balloon device in xml <memballoon model="none"/> // Not essential

 

2.5. Host looking-glass service on Windows VM failed to start. Logs in C:\\ProgramData\Looking glass. "Failed to find a supported capture interface" // HDMI Dummy plug is needed

3. Start VM -> On the host machine start $ looking-glass-client -> a window should be opened

4. 

 

 

 

 

4. Windows VM Install NVIDIA Drivers nvidia.com/Download/index.aspx -> GeForce RTX 5070 Max Q -> Download Game Ready or Studio driver -> Run installer -> Select "Custom Installation" -> Check "Perform clean installation"

 

 

 

4.1. Command Prompt -> nvidia-smi

5. Start looking-glass-host-service.exe in Windows.

6.  Client and host version should match.

 

 

Nvidia Error 43

4.2. Windows Device manager -> Videoadapter -> NVIDIA GeForce RTX 5070 Laptop GPU shows yellow triangle -> Properties Error 43

4.3. Try poweroff laptop, detattach power cable for 10 sec. // doesn't work

4.4. Edit the VM XML

<hostdev mode='subsystem' type='pci' managed='yes'>

  <source>

    <address domain='0x0000' bus='01' slot='00' function='0'/>

  </source>

  <rom file='/var/lib/libvirt/roms/your_gpu_bios.rom'/>

</hostdev>

 

 

5. VBIOS Dump

5.1. Download ROM techpowerup.com/vgabios/?architecture=NVIDIA&manufacturer=&model=RTX+5070&interface=&memType=&memSize=&since=

5.1.2. Your Device Id should match to lspci.

5.1.3. Give libvirt permission to read it $ sudo chown libvirt-qemu:libvirt-qemu /var/lib/libvirt/roms/your_gpu_bios.rom // VM doesn't start because can't find the rom file

5.2. Grab the BIOS directly from the hardware

# Navigate to the GPU directory

$ cd /sys/bus/pci/devices/0000:01:00.0/

$ echo 1 | sudo tee rom

$ sudo cat rom > ~/gpu_bios.rom

$ echo 0 | sudo tee rom

5.2.1. Validation: Check the file size. $ ls -lh ~/gpu_bios.rom // If it is around 128KB to 1MB, you have it!

 

6. Download MSI Mode Utility V3 -> Run it as Administrator. -> Find your NVIDIA RTX 5070. -> Check the box under the "MSI" column. -> Change "Interrupt Priority" to High. -> Click Apply and Reboot the VM.  // Doesn't work

 

VIRTUALIZATION PACKAGES INSTALLATION

Essential

1. qemu-kvm hypervisor (emulates hardware for VMs) essential for VM.

2. libvirt-daemon-system Provides a stable API for tools like virt-manager (GUI) and virsh. Essential for GPU passthrough configuration (e.g., binding devices to vfio-pci)

3. virt-manager GUI for managing VMs (not essential)

4. ovmf UEFI firmware for VMs.

5. $ sudo apt install qemu-kvm libvirt-daemon-system virt-manager ovmf

 

Optional

5. libvirt-clients CLI tools (virsh, virt-install) for scripting/automation.

6. bridge-utils Configures network bridges (needed for VMs to access the network).

7. virt-viewer Lightweight VM display client (alternative to virt-manager's viewer).

8. cpu-checker Verifies CPU virtualization support (e.g., Intel VT-x/AMD-V).

 

Non-essential

libguestfs-tools Advanced guest filesystem tools (e.g., mounting VM disks).

spice-client-gtk libspice-server1 SPICE protocol tools (for remote display/audio).

ibverbs-providers Infiniband/RDMA support (irrelevant for most GPU passthrough setups).

libusb-1.0-0 USB device access (only needed if passing through USB controllers).

 

sudo virt-host-validate  # Checks CPU/IOMMU/KVM readiness

sudo usermod -aG libvirt,kvm $(whoami)  # Grant VM control access

 

CREATE VM

Binding the Discrete GPU to vfio-pci

1. This will impaire ability of host system to use GPU. 

VirtIO-GPU for VMs (for Linux)

1. I prefer this solution instead of direct GPU pass trough. No IOMMU isolation, driver blacklisting, or initramfs tweaks required. Just enable the VirtIO-GPU device in the VM (via virt-manager or XML).

virtio-fs

DEBIAN

2. Virt-manager add filesystem -> Driver virtio-9p and in Memory tab check Enable shared memory

<filesystem type='mount' accessmode='mapped'>

  <source dir='{path to your shared folder on host machine'/>

  <target dir='hostshare'/>

</filesystem>

2.1. $ sudo mkdir -p /mnt/shared

2.2 $ sudo mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/shared  // Now you be able to access shared folder

 

Verify VirtIO‑GPU Is Working Inside the VM

1. $ sudo apt install mesa-utils -> $ glxinfo | grep "OpenGL renderer" Expected output (with 3D acceleration enabled): OpenGL renderer: virgl (Gallium 0.4 on llvmpipe) or similar. If you see “llvmpipe” without “virgl”, the acceleration may not be active.

2. $ glxgears The frame rate (FPS) will be displayed in the terminal. With virgl, you should get 200–300 FPS

3. $ lsmod | grep virtio_gpu It should show virtio_gpu , means kernel has the VirtIO‑GPU driver loaded.

 

 

Creating virtual machine

1. $ startx -> $ virt-manager -> Create a new virtual machine

USB

2. Mount USB with ISO file. Connect USB -> check it's connected with $ lsblk -f -> create directory $ sudo mkdir -p /mnt/usb -> $ sudo mount /dev/sda1 /mnt/usb -> $ ls /mnt/usb -> to unmount $ sudo umount /dev/sdb1

2.1 For MAC OS add line to basic.sh args -usb -device usb-host,hostbus={from $ lsusb},hostaddr={from $ lsusb} \

2.2. The problem is the system will not start without usb been connected.

Shared folder for collaborative workspaces

 

 

WINDOWS

3.1 For Windows Guests: Install Virtio drivers for 9p/Virtio-FS support from fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso add storage CD into virt-manager configuration.

3.2. Open VM -> open Device Manager -> unknown “PCI Device” -> Update drivers -> Navigate to your iso -> vioserial/w7/amd64

 

MAC OS VM

1. $ git clone https://github.com/kholia/OSX-KVM.git

2. $ python3 fetch-macOS-v2.py

3. $ qemu-img convert BaseSystem.dmg -O raw BaseSystem.img or $ dmg2img -i BaseSystem.dmg BaseSystem.img // analogue of .iso

4. $ qemu-img create -f qcow2 mac_hdd_ng.img 64G

5. Create from existing disc image.

6. In settings add a second boot OpenCore disk Add Hardware -> Storage -> Select or create custom storage from OpenCore.qcow2 (from OpenCore folder)

6.1 In settings add a second boot CDROM disk Add Hardware -> Storage -> Select or create custom storage from BaseSystem.img

7. Select Boot Options -> set new second disk as first

8. Basic test if EFI works $ qemu-system-x86_64 -drive file=OpenCore.qcow2,format=qcow2 -m 512 -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=pflash,format=raw,file=/usr/share/OVMF/OVMF_VARS.fd -vga std

9. github.com/notAperson535/OneClick-macOS-Simple-KVM works

9.1. ./fetch-macOS-v2.py

9.2. qemu-img convert BaseSystem.dmg -O raw BaseSystem.img

9.3. qemu-img create -f qcow2 macOS.qcow2 64G

9.4. sudo ./make.sh --add // import to virtual-manager

9.5. Add manually hard disk macOS.qcow2 in virtual manager GUI.

9.6. Find biggest HDD -> Erase or Format -> macOS Extended Journaled, NOT case-sensitive -> name Macintosh SSD

 

10. To run VM sudo ./basic.sh from folder /distr/mac3

 

SHARED FOLDER

3. $ sudo mount -t virtiofs shared /mnt/shared

Or create a shared disk image (QCOW2) $ qemu-img create -f qcow2 shared_disk.qcow2 10G

 

Hybrid NFS

NFS SERVER

0. I will create file server from one of my laptop at local net.

1. For linux on server laptop Install NFS Server $ sudo apt install -y nfs-kernel-server // check status $ systemctl status nfs-kernel-server

1.1 $ sudo mkdir -p /srv/nas

2. To $ sudo nano /etc/exports type /srv/nas 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash) -> $ sudo exportfs -a

CLIENT

3. Client setup. # Install NFS client utilities $ sudo apt install -y nfs-common 

6. On client $ sudo mkdir -p /mnt/shr 

7. $ sudo mount -t nfs4 -o rw,hard,intr 192.168.1.4:/srv/shr /mnt/shr // That is basically supposed to be a final step if everething is alright

8. Testing and troubleshooting: $ ping -c 4 192.168.1.4 $ nc -zv 192.168.1.4 2049

FOR WINDOWS

1. Go to Control Panel → Programs → Turn Windows features on or off -> Tick Services for NFS → Client for NFS

2. From file Explorer -> Connect net drive -> \\192.168.1.10\srv\nas

3. Since Windows 8 they stopped support NFS. They natively support Samba.

SAMBA SERVER

1. $ sudo apt install samba

2. $ sudo nano /etc/samba/smb.conf  add to the end

[shared]

   path = /srv/nas

   browseable = yes

   read only = no

   guest ok = yes

   force user = nobody

3. sudo systemctl restart smbd

4. On Windows 8 client in file explorer \\192.168.1.10\shared  -> Map as network drive

 

 

BRIDGE INSTEAD OF NAT

0. VM has problem to mount NFS share folder alegedly because of NAT configuration. Let's move to bridge.

1. $ ip link show // shows name of bridge interface

1.1 $ sudo apt install -y bridge-utils

2. Create bridged network

cat << EOF | sudo tee /tmp/br0-network.xml

<network>

  <name>br0</name>

  <forward mode='bridge'/>

  <bridge name='br0'/>

</network>

EOF

3. $ sudo virsh net-define /tmp/br0-network.xml -> $ sudo virsh net-start br0 -> $ sudo virsh net-autostart br0

4. Create the bridge interface

$ sudo ip link add name br0 type bridge

$ sudo ip link set br0 up # Bring the bridge up

$ sudo ip link set enp3s0{change to your interface} master br0 # Add your physical interface to the bridge

4.1 or edit /etc/network/interfaces

auto enp3s0

iface enp3s0 inet manual

auto br0

iface br0 inet static

    address 192.168.1.100

    netmask 255.255.255.0

    gateway 192.168.1.1

    dns-nameservers 8.8.8.8 8.8.4.4

    bridge_ports enp3s0

    bridge_stp off

    bridge_fd 0

5. This works only for enp adapter. Wont work for wifi.

6. You need to flush ip addr of phisical ethernet adapter $ ip addr flush enp109 and insted assign ip addr to br0 like $ sudo ip addr add 192.168.1.x/24 dev br0

 

 

NFSv4

 

SAMBA

 

3. Disks are here /var/lib/libvirt/images/

4. Check "Customize configuration before install" -> Firmware to UEFI /usr/share/OVMF/OVMF_CODE_4M.fd  -> Disk bus dropdown, choose VirtIO -> Video model Virtio + checkbox 3D Acceleration -> Display: activate OpenGl checkbox

 

Clipboard sharing

1. $ sudo apt install spice-vdagent -> $ systemctl status spice-vdagentd

 

How to Pass a USB Device to a Virtual Machine

1. $ lsusb and $ lsblk -f 

2. In VM -> $ virt-manager -> Add Hardware -> USB Host Device -> Select your USB device (according to $ lsusb)

 

AUDIO SOUND setup

1. Install $ sudo apt install alsa-utils

1.1. Test $ aplay -l

1.1.1 test sound on linux cli $ speaker-test -D hw:1,0 -c 2 -t wav

1.2. Open $ alsamixer -> F6 -> check there is no MM (mute)

2. $ sudo usermod -aG audio libvirt-qemu

3. Sound doesnt go on virtual machine check log $ sudo tail -n 50 /var/log/libvirt/qemu/win8.log

3.1. I see:

alsa: failed to open default:

alsa: Reason: permission denied

ALSA lib conf.c:4123:(config file open) cannot access file /etc/asound.conf

ALSA lib conf.c:4043:(snd_config_hook_calls) function snd_config_hook_load returned error: Permission denied

ALSA lib conf.c:4050:(snd_config_update_r) hooks failed, removing

alsa: could not initialize ADC

3.2. AppArmor blocks access to sound. $ sudo nano /etc/apparmor.d/abstractions/libvirt-qemu write to the end

/etc/asound.conf r,

/dev/snd/ r,

/dev/snd/** rw,

3.3. $ sudo systemctl reload apparmor

4. Now log showing:

alsa: Couldnt initialize DAC

alsa: Failed to open default

alsa: Reason no such file or directory

audio: Couldnt create a backend for voice 'dac'

4.1. We need to activate multiple access to soundcard

5. In /etc/libvirt/qemu.conf define security_driver = "none"

5.1. /etc/asound.conf 

pcm.!default {

    type plug

    slave.pcm "hw:1,0"

}

ctl.!default {

    type hw

    card 1

}

6. This ALSA doesnt work. I will try Pulseaudio.

PULSEAUDIO

1. Installation $ sudo apt install pulseaudio pulseaudio-utils

2. Start manually $ pulseaudio --start --exit-idle-time=-1 // VM works now.

3. But I want to make mic unreachable for Windows OS.

3.1. Find mic name $ pactl list sources short

3.2. Switch off

pactl set-source-mute name_of_mic 1

pactl set-source-volume name_of_mic 0%

3.3. To make mic off persistent to survive reboot write it to ~/.config/pulse/default.pa

set-source-mute name_of_mic 1

set-source-volume name_of_mic 0

 

 

TROUBLE SHOOTING

1. virtual machine suddenly doesn't start : Error starting domain: Requested operation is not valid nework default is not active.  asyncjob.py in cb_wrapper tmpcb virtManager/object/libvirtobject.py in newfn domain.py in startup self._backend.create() libvirt.py in create raise libvirtError('virDomainCreate() failed) requested operation is not valid network default is not active // $ sudo virsh net-start default

2. When I ran sudo mount 192.168.1.4:/srv/shr /mnt/shr I get mount.nfs4: Operation not permitted for 192.168.1.4:/srv/nas on /mnt/shr  // The problem with subnet. VM behind NAT. Try bridge setup.

3. Bridge is working but host stops connecting internet. // Default gateway is missed on host. $ sudo ip route add default via 192.168.1.1 dev br0

 

 

Configure Libvirt for GPU Access

 

 

 

2. $ sudo ip link set wlp108s0 up doesn't set interface up, interface still down despite there are no warnings.

3. What if after hiberanation I lost wifi driver. $ ip link show doesn't show wlp interface anymore with message rtw89_8852ce 0000:6c:00.0 mac init fail, ret: -110

 

fix. Update kernel drivers

sudo apt update && sudo apt upgrade

sudo apt install firmware-realtek linux-headers-$(uname -r)

 

CUDA usage

1. Install drivers $ pacman -Syu && $ pacman -S nvidia-utils cuda cuda-tools nvidia-settings

2. $ nvidia-smi command form VM Archlinux produces error NVIDIA-SMI has failed because of communication with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

$ lspci -nnk | grep -A3 -i nvidia shows 05:00.0 VGA Compatible controller NVIDIA Corporation CB206M Geforce RTX 5070 Max-Q but "Kernel driver in use" is not present.

2.1. try

$ sudo pacman -Syu

$ sudo pacman -S linux-headers nvidia-dkms nvidia-utils

$ sudo reboot

 

 

llama.cpp is a best choice

$ git clone https://github.com/ggerganov/llama.cpp

$ cd llama.cpp

$ make

 

How to run nvidia-smi inside docker container? Is nvidia-container-toolkit package should be installed?

 

Your RTX 5070 supports FP4 this can effectively double your "perceived" VRAM, allowing you to run models that normally require 16GB on your 8GB card with surprisingly little quality loss.