1

I've been struggling with various tutorials to hook up my /dev/ttyACM0 in a lxc container.

Basically I've tried adding the following line in my lxc config :

lxc.cgroup.devices.allow = c 166:* rwm

And the following one too (both with relative and full path) :

lxc.mount.entry = /dev/ttyACM0  dev/ttyACM0  none  bind,optional

but yet, I can't get a working configuration.

FYI on the host side the modem is working and my host shows up :

$ ll /dev/ttyACM0
crw-rw---T 1 root dialup 166, 0 janv. 29 16:47 /dev/ttyACM0
Cerber
  • 1,101
  • 1
  • 10
  • 23

1 Answers1

1

I don't have a modem, but I tested with my pendrive to connect it direct with the container.

My device on the host:

    brw-rw---- 1 root plugdev 8, 16 Jan 29 15:17 /dev/sdb

My container config:

    ...
    lxc.cgroup.devices.allow = b 8:16 rwm
    lxc.mount.entry = /dev/sdb /var/lib/lxc/multi2/rootfs/dev/sdb none bind 0 0

But when try to start it, I got the following error:

    ERROR    lxc_conf - No such file or directory - failed to mount '/dev/sdb' on '/var/lib/rootfs-lxc//dev/sdb'

Then I tried to create the device file in the container /dev:

    sudo touch /var/lib/lxc/multi2/rootfs/dev/sdb

When I tried start it again, it worked! In the container console:

    root@multi2:~# ls -l /dev/sdb 
    brw-rw---- 1 root plugdev 8, 16 Jan 29 15:17 /dev/sdb
    root@multi2:~#  fdisk -l /dev/sdb

    Disk /dev/sdb: 1000 MB, 1000341504 bytes
    251 heads, 2 sectors/track, 3892 cylinders, total 1953792 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x784ffaa9

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048     1943551      970752    b  W95 FAT32

Everything as expected.

Eduardo Ramos
  • 268
  • 1
  • 6
  • It Works! Nice! I'll take some time later today to be sure but I think it was due to the fact that I was told do do a `mkdir` where you did a `touch` (and didn't think about it) – Cerber Jan 30 '15 at 09:52
  • @Eduardo Ramos - I'm trying to do this on unprivileged container (lxc 2.0.7) but I can't get past the error that you mention – Shady Programmer Mar 24 '17 at 16:32