LXC with CUPS and /dev/usb/lp0

Dec 29, 2017
7
6
8
49
Hi.
I'm trying to convert a KVM machine with Ubuntu 15.10 to a LXC 17.10 with CUPS and passthrough a USB printer. (Brother HL-2130). I'm using VE 5.1-41.

I've managed to get it working, but only works if in the host the file /dev/usb/lp0 exists. I can see that this file is created when the KVM machine is started, and if I stop it, the file doesn't delete which allow me to start the LXC.
The reason why this file is needed is because I've in my LXC config this lines:

Code:
lxc.cgroup.devices.allow: c 189:* rwm
lxc.mount.entry = /dev/usb/lp0 dev/usb/lp0 one bind,create=file 0 0

Without those lines, the printer is recognized by CUPS but it really doesn't work. (More info: https //forum.proxmox.com/threads/lxc-usb-passthrough-zwave-stick.30058/ and https //forum.turris.cz/t/lxc-usb-printer-passthrough/2130)

But, if I don't start the KVM from a cold reboot (which obviously is the idea), the /dev/usb/lp0 is not created and when I start the LXC an error shows up:

Code:
~# /usr/bin/lxc-start -n 107 -F
lxc-start: 107: cgroups/cgfsng.c: create_path_for_hierarchy: 1337 Path "/sys/fs/cgroup/systemd//lxc/107" already existed.
                                                                                                                         lxc-start: 107: cgroups/cgfsng.c: cgfsng_create: 1433 Failed to create "/sys/fs/cgroup/systemd//lxc/107"
                                                                                                                                                                                                                                 lxc-start: 107: utils.c: safe_mount: 1707 No such file or directory - Failed to mount /dev/usb/lp0 onto /usr/lib/x86_64-linux-gnu/lxc/rootfs/dev/usb/lp0
                                                                                                         lxc-start: 107: conf.c: mount_entry: 1854 No such file or directory - Failed to mount "/dev/usb/lp0" on "/usr/lib/x86_64-linux-gnu/lxc/rootfs/dev/usb/lp0"
                                                                                                                                                                                                                                                                   lxc-start: 107: conf.c: lxc_setup: 3188 failed to setup the mount entries for '107'
                                                                      lxc-start: 107: start.c: do_start: 944 Failed to setup container "107".
                                                                                                                                             lxc-start: 107: sync.c: __sync_wait: 57 An error occurred in another process (expected sequence number 5)
                                                                                                                                                                                                                                                      lxc-start: 107: start.c: __lxc_start: 1477 Failed to spawn container "107".
                                                 lxc-start: 107: tools/lxc_start.c: main: 371 The container failed to start.
lxc-start: 107: tools/lxc_start.c: main: 375 Additional information can be obtained by setting the --logfile and --logpriority options.

So the question is: How can I create the /dev/usb/lp0 for the LXC to start, the same way the KVM is handling that.

When I start the KVM, I see this in the host log:

Code:
pve kernel: usb 3-9.3: usbfs: interface 0 claimed by usblp while 'kvm' sets config #1

Thank you very much.
 
I've tried also, after a cold reboot, to run "modprobe usblp" on the host, and start the lxc, but the error persists.
 

About

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!