Howto: LE 12 as a Proxmox VM with GPU pass-through on Intel N150

  • This is a work-in-progress thread, I'll try to document what works and what doesn't.

    Goal:

    I have a GMKtec G3 plus mini pc, with an Intel N150 CPU. I wanted to run Proxmox on it to host my home VMs/containers. The most crucial role that the system was bought for was serving as my bedroom LibreELEC to drive my TV.

    Intended audience:

    You should probably feel at home with the Proxmox Virtualization Environment (PVE). It's an excellent hypervisor with a very friendly community.

    Initial setup:

    Make sure that on the system UEFI is enabled as well as all virtualization options (Intel VT, VT-d, IO-SRV if present).

    I will not cover the Proxmox initial installation procedure. I followed the defaults and that was it.

    You'll need a copy of a specially created LE build, see RE: LE 12.0 added lvm2, luks (dm-crypt, veracrypt), mdraid, ext4 encryption

    From the link, download the img.gz version written to a thumb drive, using the LibreELEC USB Creator application.

    Create a VM say libreelec with the defaults. I gave 4 vCPUs and 32Gb of disk. Do not change the GPU type. BIOS should be (by default) SeaBIOS, which is ok.

    Connect the thumb-drive to the system and from within proxmox add it as USB device, using pass-through. Boot from that and just do a LibreELEC install. Let it reboot after install, it will be stuck in the LE logo screen, that's ok. Power it down.

    The actual stuff:

    Now comes the hard part, pass through the graphics adapter. First add some modules to /etc/modules, so the file looks like this (see [1]):

    Code
    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with "#" are ignored.
    # Parameters can be specified after the module name.
    intelvfio
    vfio_iommu_type1
    vfio_pci

    Immediately afterwards run:

    Code
    update-initramfs -u -k all

    The kernel should also be started with an iommu=pt option (see also [1], plus how to do it in [2]). Basically, edit /etc/default/grub and
    set variable GRUB_CMDLINE_LINUX_DEFAULT to be "quiet iommu=pt" instead of "quiet".
    Save and do a:

    Code
    grub-update

    Reboot.

    Now you'll have to locate which is the PCI id of your graphics card. You do that by running a (sample output included):

    Code
    root@pve:~# lspci -nnv |grep -i vga
    00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-N [Intel Graphics] [8086:46d4] (prog-if 00 [VGA controller])

    So the id is the one ending in 00:02.0. Now go to the LE VM configuration and add a PCI device. Select Raw device and from the pull down menu select the device ending in the code corresponding to your VGA. Check the Primary GPU box. Do not touch anything else!

    At this point, being optimists we'll expect that everything will work, so this is the type to connect a USB keyboard to the box (if you have disconnected it before) and pass through the USB device that corresponds to your keyboard (Add USB device -> Use USB Vendor/Device ID).

    Start your VM. If everything went fine, the console display of proxmox will be replaced with the librelec boot screen and, finally, with the LE configuration wizard.

    For the record this is how my vm.conf file looks like:

    Final thoughts:

    As this is WIP, I have not tested audio (currently connected to a computer monitor with no audio, but expect that it will work over HDMI). If not, the guide will be modified to reflect any changes.

    Additionally, I do want to have some smart hibernation of the VM. If I find anything, I'll update the howto as well.


    References:

    [1]: Proxmox PCI(e) Passthrough

    [2]: Proxmox Editing the Kernel Commandline