[lxc-users] How to have /var, /tmp etc. on separate zfs filesystems in containers?

Korn András korn-lxcusers at elan.rulez.org
Mon Mar 4 19:30:26 UTC 2019


On Mon, Mar 04, 2019 at 09:38:45PM +0300, Andrey Repin wrote:

Hi,

> > I'd like to have separate zfs datasets for /var, /tmp and some other
> > mountpoints inside my guests.
> 
> > What's a good way of achieving this?
> 
> > As far as I could determine from looking at the source, the zfs storage
> > backend doesn't support anything like it, and lxc-create doesn't run any
> > hooks.
> 
> > Should I instead write a wrapper around lxc-create that creates and mounts
> > my zfs datasets just so, and calls lxc-create with the 'dir' storage
> > backend?
> 
> > Or is there a better way?
> 
> If I may hazard a guess, there's two ways to achieve this:
> 
> 1. Rebind the directories individually.
>   Use lxc.mount.* commands in the config or specify lxc.mount.fstab file with
>   your bindings.

Yes, that works once the container exists. During the lxc-create phase, however,
/var would be populated as a subdirectory of the monolithic rootfs; I'd then
need to rename that var/ directory, create my new fs in its place, then move
stuff from oldvar/ to var/. Rinse and repeat for all/any other filesystems
I'd like to split out.

I'm looking for a way to have lxc-create create the filesystems and mount
them; ideally, there'd be an lxc.hook.create that I could use (from the
default config), but there isn't, so it looks like I can either

 * do the rename; create fs; move files dance each time OR

 * write a wrapper around lxc-create.

(Or improve the zfs storage backend, but I can't invest that much time.)

Am I missing anything?

András

-- 
                     The bride got a new name and a dress.


More information about the lxc-users mailing list