[lxc-users] Adding a host block device to a container
Serge Hallyn
serge.hallyn at ubuntu.com
Tue Sep 1 16:15:36 UTC 2015
Quoting Peter Steele (pwsteele at gmail.com):
> On 09/01/2015 07:25 AM, Serge Hallyn wrote:
> >FWIW there is a lxc-device command that will do the mknod for you,
> >but it won't be persistent (iirc). Support for making that
> >persistent would be welcome. I think that would come in three small
> >pieces:
> >
> >. have src/lxc/lxc_device optionally save the container configuration
> > when done.
> >. have do_add_remove_node() manipulate a new list of devices to be
> > created at container start.
> >. have src/lxc/conf.c:fill_autodev create devices which are in the new
> > list
>
> I definitely want this to be persistent, and in my case it's
> intended to be all part of an automation process. The containers are
> created programmatically and certain types of containers will be
> assigned certain block devices. Once this setup is done, the
In that case that's exactly what templates were meant to do. So while
I'd still like to see lxc-device updated to support persistence, you
could do what you want by
1. creating a lxc.hook.autodev hook which creates the device you want
using mknod,
2. adding lxc.hook.autodev = /usr/local/bin/my-dev-hook to the container
configuration
3. adding the lxc.cgroup rule you need to the container configuration
You could add the two config additions to your global
/etc/lxc/default.conf, add them to the config you pass to
lxc-create -f, or set them in a new template you create and use
instead of /bin/true.
More information about the lxc-users
mailing list