Skip to content

Instantly share code, notes, and snippets.

@jonoharms
Created February 3, 2025 11:01
Show Gist options
  • Save jonoharms/6467d78bad4d79289c3df575f7694eb7 to your computer and use it in GitHub Desktop.
Save jonoharms/6467d78bad4d79289c3df575f7694eb7 to your computer and use it in GitHub Desktop.
setup virtual intel gpu on proxmox 8.3
# ref https://www.derekseaman.com/2024/07/proxmox-ve-8-2-windows-11-vgpu-vt-d-passthrough-with-intel-alder-lake.html
---
- hosts: pve
vars_prompt:
- name: mok_password
prompt: What is your mok password?
tasks:
- name: install deps
ansible.builtin.apt:
pkg:
- sysfsutils
- pve-headers
- mokutil
- git
- build-essential
- dkms
- python3-pexpect
- proxmox-headers-6.11
update_cache: true
state: latest
# - name: unpin kernel version
# ansible.builtin.expect:
# command: proxmox-boot-tool kernel unpin
# responses:
# Refresh.*: "y"
- name: Analyzing the directories to delete...
ansible.builtin.find:
paths:
- /var/src/
- /var/lib/dkms/
- /root/
patterns:
- "i915-sriov-dkms-*"
- "i915-sriov-dkms"
use_regex: true
file_type: directory
register: folders_to_delete
- name: Displaying the result...
debug:
var: folders_to_delete
- name: Deleting the directories...
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ folders_to_delete.files }}"
- name: Analyzing the directories to delete...
ansible.builtin.find:
paths:
- /lib/modules/
patterns:
- ".*/updates/dkms/i915.ko"
use_regex: true
register: kernels_to_delete
- name: Displaying the result...
debug:
var: kernels_to_delete
- name: Deleting the kernels...
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ kernels_to_delete.files }}"
- name: Read-write git checkout from github
ansible.builtin.git:
repo: https://github.com/strongtz/i915-sriov-dkms.git
dest: /root/i915-sriov-dkms/
- name: dkms add
ansible.builtin.command:
cmd: dkms add .
chdir: /root/i915-sriov-dkms/
- name: dkms status
ansible.builtin.command:
cmd: dkms status -m i915-sriov-dkms
chdir: /root/i915-sriov-dkms/
register: dkms_status
- name: get dkms version
ansible.builtin.set_fact:
dkms_version: "{{ ( dkms_status.stdout | split(':') )[0] }}"
- name: dkms install
ansible.builtin.command:
argv:
- dkms
- install
- -m
- "{{ dkms_version }}"
- --force
chdir: /root/i915-sriov-dkms/
- name: mok import
ansible.builtin.expect:
command: mokutil --import /var/lib/dkms/mok.pub
responses:
.*password: "{{ mok_password }}"
no_log: true
- name: Modify boot config
ansible.builtin.lineinfile:
path: /etc/kernel/cmdline
regexp: '^root=ZFS=rpool/ROOT/pve-1 '
line: root=ZFS=rpool/ROOT/pve-1 boot=zfs intel_iommu=on iommu=pt i915.enable_guc=3 i915.max_vfs=7
- name: refresh bootloader
ansible.builtin.command: proxmox-boot-tool refresh
- name: pci config
ansible.builtin.lineinfile:
path: /etc/sysfs.conf
regexp: '^devices/pci0000'
insertafter: EOF
line: "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 7"
# - name: Reboot machine and send a message
# ansible.builtin.reboot:
# msg: "Rebooting machine in 5 seconds"
# - name: pin kernel version
# ansible.builtin.command:
# argv:
# - proxmox-boot-tool
# - kernel
# - pin
# - "{{ ansible_facts.ansible_kernel }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment