[lxc-users] Accessing /dev file system from container

Michael H. Warfield mhw at WittsEnd.com
Thu Sep 25 13:43:01 UTC 2014

On Thu, 2014-09-25 at 13:04 +0000, Murthy, Krishna J wrote:
> I have a Ethernet device which is attached to the container. I have
> installed the driver module for this device on the host. When I run
> the application on the container it complains it is unable to find the
> device in the /dev file system. Infact I use UIO based driver. So in
> container I get message unable to access /dev/uio0: No such file or
> directory. 

Each container has its own /dev space, which can be static on a file
system, a tmpfs mount, or a bind mount.  In particular, if you're
running systemd in the container (Fedora, SuSE, Oracle 7, CentOS 7, etc)
it should be a bind mounted subdirectory of the hosts /dev/ space,
under /dev/.lxc, which is mounted with devtmpfs.  Because of device
conflicts and contention between the containers' /dev and the host /dev,
it is not possible to share the root devtmpfs with the container.

There is a utility for moving a device into a container, aptly named
lxc-device.  Run that in the host and you should be able to add a device
into the container...

lxc-device -n {container} add /dev/uio0

That should be all you need in this particular case.

There are other techniques which can be used within the host devtmpfs
space but everything has to be done in the host namespace.  You may also
have to update the cgroups for the devices that are allowed.

All of this can be done from udev rules in the host.

> Regards,
> Krishna 
> --------------------------------------------------------------
> Intel Shannon Limited
> Registered in Ireland
> Registered Office: Collinstown Industrial Park, Leixlip, County
> Kildare
> Registered Number: 308263
> Business address: Dromore House, East Park, Shannon, Co. Clare
Michael H. Warfield (AI4NB) | (770) 978-7061 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 465 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20140925/de21553f/attachment.sig>

More information about the lxc-users mailing list