Adding multiple identical USB devices to different LXD instances


#1

Hi all

I read the following guide on how to add USB devices to an LXD container. Sounds so remarkably easy!

However, I would like to add multiple identical USB devices to a Linux host and have each device be connected to its own LXD container :slight_smile:

How would I go about doing that?


Add multiple USB devices with same PID/VID
#2

When you connect a USB device to the host, udev runs and configures the device. Depending on how different or similar the devices are, you can add here some sort of differentiation. One way to differentiate USB devices that have the same Vendor and Product IDs, is the USB port that you have connected them through. See, for example, at https://www.linuxquestions.org/questions/linux-general-1/udev-rules-to-differentiate-between-multiple-identical-devices-822879/ or https://askubuntu.com/questions/722550/use-udev-to-rename-devices-with-same-properties on how to differentiate those otherwise identical devices. You would change their Vendor or Product IDs to values that you have configured into the LXD configuration.

LXD can differentiate USB devices according to the Vendor and Product IDs, https://github.com/lxc/lxd/blob/master/doc/containers.md#type-usb


#3

Thanks very much for those links :slight_smile:


(Ghoshan J) #4

I have read the information in the links and would like to know how I can "change their Vendor or Product IDs to values that you have configured into the LXD configuration.

I know udev allows to create symlinks for devices to differentiate them. But I need to change the pid/vid so that I can add the different devices to different containers.