[TUTORIAL] PCI/GPU Passthrough on Proxmox VE 8 : Debian 12 (with Cloud-init)


Sep 2, 2022
This article is the third in a series of five articles dealing with the installation and configuration of VMs (Linux, Windows, macOS and BSD) in PCI Passthrough on Proxmox VE 8.

Well, after seeing how to configure our first Windows VMs, let's now move on to Linux (Debian 12). For this installation we will use cloud-init, still in the same logic as before (with our installations of Windows 10 and 11), that is to say the facilitation of the deployment of our future templates.

Creating our Debian VM

We start by creating our VM:

 qm create 106 \
--name deb-106\
--agent 1\
--memory 8192\
--bios ovmf\
--sockets 1 --cores 4\
--cpu host\
--net0 virtio,bridge=vmbr0\
--scsihw virtio-scsi-single\
--boot order='scsi0'\
--efidisk0 local-lvm:0\
--ide0 local-lvm:cloudinit\
--machine q35\
--hostpci0 0000:01:00,pcie=1,x-vga=1 \
--serial0 socket\
--vga serial0\
--usb0 046d:c08b,usb3=1\
--usb1 04ca:007d,usb3=1
A few details on the QEMU configuration applied:

  • ide0 local-btrfs:cloudinit This is our Cloud-init disk.
  • boot order=‘scsi0’ In the boot order, I defined our future Debian image, in first position (we will see later how to add it to this config).
  • hostpci0 0000:01:00,pcie=1,x-vga=1 the PCI slot of our graphics card.
  • vga serial0 and serial0 socket set default display to serial console output (default configuration for cloud init).
  • usb0 and usb0: correspond to the USB id's of my keyboard and my mouse, which I retrieved from the hypervisor with ”lsusb”.

  • Importing the Debian image for our VM

    Let's get our Debian cloud image, it's the "generic" we need:

    wget -P /mnt/pve/PVE1/template/iso/ https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
    We add our disk image in our QEMU configuration

    qm set 106 --scsi0 local-lvm:0,import-from=/mnt/pve/PVE1/template/iso/debian-12-generic-amd64.qcow2
    We take the opportunity to resize our disk, just to have enough space to install all the packages:

    qm resize 106 scsi0 50G
    Customizing our Debian image

    Now we can move on to editing our configuration file, to adapt our Debian image.

    Indeed, the image does not have a GUI, moreover, it also does not have the necessary AMD drivers for my RX 580. To do this, we will first have to add, new entries to apt sources “contrib, non-free and non-free-firmware” we will then define the additional packages to install.

    In my case I will store my config file in "/mnt/pve/PVE1/snippets", but that's because I have an NFS mount point to my NAS. In your case the path should be “/var/lib/vz/snippets”.

    cat << EOF >> /mnt/pve/PVE1/snippets/deb12.yaml
    - path: /etc/apt/sources.list.d/non-free-contrib.list
    happy: |
    deb http://deb.debian.org/debian/bookworm main contrib non-free non-free-firmware
    deb-src http://deb.debian.org/debian/bookworm main contrib non-free non-free-firmware
    deb http://security.debian.org/bookworm-security main contrib non-free non-free-firmware
    deb-src http://security.debian.org/bookworm-security main contrib non-free non-free-firmware
    deb http://deb.debian.org/debian/bookworm-updates main contrib non-free non-free-firmware
    deb-src http://deb.debian.org/debian/bookworm-updates main contrib non-free non-free-firmware
    package_update: true
    package_upgrade: true
    - qemu-guest-agent
    - vim
    - net-tools
    - htop
    - gnome-core
    - xserver-xorg-video-amdgpu
    - firmware-amd-graphics
    - libgl1-mesa-dri
    - libglx-mesa0
    - mesa-vulkan-drivers
    - systemctl enable qemu-guest-agent
    - systemctl start qemu-guest-agent
    - mkdir -p /etc/skel/Documents
    - mkdir -p /etc/skel/Images
    - mkdir -p /etc/skel/Videos
    - mkdir -p /etc/skel/Downloads
    - mkdir -p /etc/skel/Skeles
    - echo 'SKEL=/etc/skel' >> /etc/adduser.conf
    -userdel -r -f debian
    In addition to our configuration file, we will additionally define the type of IP assignment (dhcp in my case since I want to make desktop use of it, a static IP does not interest me).

    qm set 106 --ipconfig0 ip=dhcp
    qm set 106 --cicustom "vendor=PVE1:snippets/deb12.yaml"
    In your case, for the last command, use (default snippets path) instead:

    qm set 106 --cicustom "vendor=local:snippets/deb12.yaml"
    First setup

    We launch the installation/configuration of the VM:

    qm start 106
    At the first start our VM will install all the necessary packages, you can check this from the proxmox console. Once you have control of the console again, you can directly shut down the VM and delete the obsolete entries in the QEMU configuration.

    qm shutdown 106
    qm set 106 --vga none
    qm set 106 --delete serial0
    Conversion to template and deployment

    It's almost finished, we now move on to converting our freshly configured VM into a template:

    qm template 106
    Now all you have to do is clone your Debian template, and define your user.

    qm clone 106 107 --full 1 --name deb-107
    Setting cloud-init parameters:

    qm set 107 --ciuser USER --cipassword PASSWORD
    You can also go through the proxmox web interface to configure Cloud-init. Click on the new virtual machine you created, go to the Cloud-Init tab and then pass your settings and that's it! You can start your new virtual machine.

    My original Article (FR) : GPU passtrought sous Proxmox VE - Debian 12 (Part. 02x04)
  • Like
Reactions: mcmxvi


The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!