惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
GbyAI
GbyAI
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
B
Blog
博客园 - 叶小钗
V
Visual Studio Blog
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
博客园 - Franky
V
V2EX
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
IT之家
IT之家
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Check Point Blog
N
Netflix TechBlog - Medium
博客园 - 【当耐特】

Proxmox Support Forum

[SOLVED] - Github Auth for Mirrors-Kernel Repo? [Automation] Mass migration tool for MS Win11/Server Proxmox GUI hang - not response is it possible to reject or quarantine spam based on conditions I set ? The PVENode task list in PVE9 is partially obscured due to the terminal font being too large. About 100% error reporting due to pveproxy.service hooks Kubernetes overlay networking breaks when upgrading from PVE 9.1 to PVE 9.2.3 Zentraler Speicher No space left on device Combine datastore and direct file archival to tape Kernel panic VFS: Unable to mount root fs on unknown-block (0,0) sobald ein 7.x Kernel verwendet wird. How to migrate disk of a VM from one ZFS to another Windows Server 2025 fails to boot after PVE 9.2 / Linux 7.0 Kernel upgrade Cannot Install Proxmox on T610 Poweredge with H700 PERC card sdn Config. gateway not reachable How to safely change domain/FQDN? Welche Filterquote erreicht ihr? NFS Share status unknown on 2 of 5 nodes Can't connect to PVE9 consoles [solved] Can't connect to PVE9 consoles [solved] [SOLVED] - Use secondary network for PVE commands Created cluster, one node storage gone BUG: proxmox mail gateway FROM = null bypass spam filtering Moving existing PBS from VMWare workstation to PVE cluster Does eBGP SDN fabric support external peering? Bug: PDM 1.1 not recognizing valid license status Proxmox GUI hang - not response PVE crashes unexpectedly Proxmox Backup Server 4.2 released! Advice
Using Resource Mappings on LXCs
invalid@exam · 2025-07-05 · via Proxmox Support Forum

Hello,

I have successfully setup an USB Device in Resource Mappings. While there is documentation on attaching Resource Mapping devices to VMs, I cannot verify if it's possible to use them for LXCs and there is no way add the device via Device Passthrough in the GUI. I took a look around at /dev and while I can see the device itself, I do not see any /dev entry that matches the name I specified in Resource Mappings.

If there is no such thing, it would be nice to be able to use Resource Mappings with LXCs. It would allow the LXC to migrate between nodes with the device and a common path; very similar to the usecase of VMs. I see there is a /dev/mapper which seems like an excellent place to put the device, in the form of /dev/mapper/<type>/<name>.

Should I add udev rules as an alternative to having a consistent (across hosts) user-friendly way to add the device to the LXC?

I want to share some Ansible tasks I have written to accomplish synchronizing Resource Mappings to /dev entries:

Code:

- name: Get PCI resource mappings
  ansible.builtin.command: pvesh get /cluster/mapping/pci --output-format json
  register: pci_resource_mappings
  changed_when: false

- name: Get USB resource mappings
  ansible.builtin.command: pvesh get /cluster/mapping/usb --output-format json
  register: usb_resource_mappings
  changed_when: false

- name: Add udev rules
  vars:
    usb_devices: "{{ usb_resource_mappings.stdout | from_json }}"
    pci_devices: "{{ pci_resource_mappings.stdout | from_json }}"
  ansible.builtin.template:
    src: 99-resource-mappings.rules.j2
    dest: /etc/udev/rules.d/99-resource-mappings.rules
    mode: "0644"
  notify:
    - Reboot

And the accompanying template:

Code:

# This file was automatically generated using Ansible.
#
# Adds stable /dev paths for devices used in Resource Mappings.

# PCI
{% for pci_device in pci_devices -%}
  {% for raw_mapping in pci_device.map -%}
    {% set mapping = raw_mapping.split(',') | map('split', '=') | community.general.dict -%}
    {% if mapping.node == inventory_hostname -%}
      {% set name = pci_device.id -%}
      {% set ids = mapping.id.split(':') -%}
      {% if "gpu".casefold() in name.casefold() -%}
## GPU
{# TODO Use mapping iommugroup, path, and/or subsystem-id #}
SUBSYSTEM=="drm", KERNEL=="card*", ATTRS{vendor}=="0x{{ ids[0] }}", ATTRS{device}=="0x{{ ids[1] }}", SYMLINK+="{{ name }}-card"
SUBSYSTEM=="drm", KERNEL=="render*", ATTRS{vendor}=="0x{{ ids[0] }}", ATTRS{device}=="0x{{ ids[1] }}", SYMLINK+="{{ name }}-render"
      {% else -%}
## Other
# TODO "{{ pci_device }}"
      {%- endif %}
    {%- endif %}
  {%- endfor %}
{%- endfor %}

# USB
{% for usb_device in usb_devices -%}
  {% for raw_mapping in usb_device.map -%}
    {% set mapping = raw_mapping.split(',') | map('split', '=') | community.general.dict -%}
    {% if mapping.node == inventory_hostname -%}
      {% set name = usb_device.id -%}
      {% set ids = mapping.id.split(':') -%}
SUBSYSTEM=="usb", ATTRS{idVendor}=="{{ ids[0] }}", ATTRS{idProduct}=="{{ ids[1] }}", SYMLINK+="{{ name }}"
    {%- endif %}
  {%- endfor %}
{%- endfor %}

This seems to work as far as creating /dev entries is concerned. I have not yet tested if these can be passed through to an LXC container yet. There are also TODOs that may be relevant to your setup to address, for example, if using IOMMU or SR-IOV. However, for me, udevadm info /dev/<name> --attribute-walk output seems promising.

Last edited:

As it turns out you cannot use the /dev/<device> in the LXC.

I was thinking as an alternative to maybe use lxc.hook in some way to modify the devX entry in config in some way (and base it off the Resource Mappings). However, if I'm understanding hooks correctly, these would run too late and wouldn't work. So I'm stumped on this.

It would be helpful if Proxmox could do this automatically. When selecting "Device Passthrough" for an LXC, you can select a Resource Mapping, and it'll automatically add the devX entry to the LXC config that points to the real /dev device. Then when the LXC migrates from one node to another, Proxmox automatically changes that config when it moves nodes to the appropriate /dev for that node as stated by the Resource Mapping.

I would like an simple solution for this too. Most times when my node restarts the use device passthrough changes and then the lxc wont boot.

I would like an simple solution for this too. Most times when my node restarts the use device passthrough changes and then the lxc wont boot.

Same here, did you find a Solution for that?