Created Mon Jan, 01 2024 at 07:26PM

I wanted to get my octoprint LXC container working with the usb serial interface hooked up to my Creality Ender 3 v2. To get it working you'll need to create udev rules, create group and edit the LXC conf file to get it to automount.

First, you'll need to find out what vendor id your usb device is. If you don't know run lsusb before and after plugging in your device.

root@mox:~# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 122: ID 1a86:7523 QinHeng Electronics CH340 serial converter
Bus 001 Device 003: ID 0d8c:0014 C-Media Electronics, Inc. Audio Adapter (Unitek Y-247A)

In my case it was 1a86:7523

# add in a group to set in the udev rule
groupadd -g 100000 lxcroot
vi /etc/udev/rules.d/99-ender3-v2.rules

then paste in the udev rule def

SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="ender3", GROUP="lxcroot"
# reload udev rules
udevadm control --reload
# apply udev rules
udevadm trigger
# check ownership of /dev/ttyUSB0 to ensure it's group is lxcroot
ls -l /dev/ttyUSB0

now edit the lxc container conf and add in

lxc.cgroup.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dir
lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file
lxc.mount.entry: /dev/ender3 dev/ender3 none bind,optional,create=file

Reboot your lxc container and octoprint should be able to connect.