[lxc-devel] How to import/access raw devices inside the container ?

Stéphane Graber stgraber at ubuntu.com
Tue Oct 8 14:23:42 UTC 2013


On Tue, Oct 08, 2013 at 07:13:51AM -0700, Gherasim Dragos wrote:
> Hello,
> 
> Wondering if someone can help me with this:
> 
> - given a host where some raw devices are setup:
> 
>  raw -qa
> /dev/raw/raw1:  bound to major 7, minor 1
> /dev/raw/raw2:  bound to major 7, minor 2
> /dev/raw/raw3:  bound to major 7, minor 3
> 
> Added the following entry in config file for the container:
> 
> lxc.cgroup.devices.allow = b 162:* rwm

Hi,

The lxc-users mailing-list would probably have been more appropriate for this.

Your listing above shows devices that are 7:* yet you're allowing 162:*,
that's not going to do you much good :)

They also won't be created in the container unless they're created by
default by udev or you're getting a matching uevent.

As those seem like virtual devices bound to a kernel module, I don't
think they'll get auto-created, so you'll need to use mknod in the
container to create the node, then you should be able to use it.

Note that I also wrote an lxc-device tool which we ship in recent LXC
and lets you add new devices to your container after boot (not
persistent though). Using lxc-device you should be able to do:
 lxc-device add -n <container-name> /dev/raw/raw1

And /dev/raw/raw1 should appear in the container and be usable (you may
have to create /dev/raw first, I'm not sure lxc-device creates missing
directories).

> 
> Yet, the raw devices are not accessible in the container:
> 
> ls -la /dev/raw/
> total 8
> drwxr-xr-x 2 root root 4096 Oct  2 09:29 .
> drwxr-xr-x 6 root root 4096 Oct  8 06:08 ..
> 
> Any ideas?
> 
> Thank you,
> Dragos


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131008/5eab2a72/attachment.pgp>


More information about the lxc-devel mailing list