Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Jun 2015 16:29:41 +0900
From:      <kikuchan@uranus.dti.ne.jp>
To:        Marcus Reid <marcus@blazingdot.com>
Cc:        <freebsd-jail@freebsd.org>, <freebsd-zfs@freebsd.org>
Subject:   Re: zfs in a jail
Message-ID:  <e684c7f412b74e203edc765c5c1406f4@imap.cm.dream.jp>
In-Reply-To: <20150613035921.GA22078@blazingdot.com>
References:  <20150613035921.GA22078@blazingdot.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

I'm doing the exec.postcreate like thing with the following way, just FYI.

in /etc/jail.conf
----
exec.start=""
exec.poststart="/jail/poststart.sh ${name}"
----

in /jail/poststart.sh
----
jid=`/usr/sbin/jls -j $1 jid`
name="$1"

# Do whatever you want to initialize the jail from host, here

# Run the command in the jail
/usr/sbin/jexec "${name}" /bin/sh /etc/rc
----

I hope this may help you.

Regards,
Kikuchan

On Fri, 12 Jun 2015 23:59:21 -0400, Marcus Reid <marcus@blazingdot.com> wrote:
> Hi,
> 
> I'm doing zfs from within a jail, and there is one thing that's giving
> me some trouble.
> 
> First, the bits that get zfs working from inside a jail:
> 
> /etc/jail.conf:
>   allow.mount;
>   allow.mount.zfs;
>   enforce_statfs = 1;
> 
> /etc/sysctl.conf:
>   security.jail.mount_allowed=1
>   security.jail.mount_zfs_allowed=1
>   security.jail.enforce_statfs=1
> 
> zfs set jailed=on zroot/jails/git/git
> 
> Finally, to get the dataset visible inside the jail, this is required
> when the jail is running:
> 
> zfs jail git zroot/jails/git/git
> 
> So, in jail.conf, I do a:
> 
>   exec.poststart = "zfs jail git zroot/jails/git/git"
> 
> Problem: zfs is not visible in jail after a reboot.  This problem is
> understood but I don't know the solution.
> 
> exec.poststart is run after exec.start (the thing that runs /etc/rc in
> the jail), so the zfs datasets are not yet visible when /etc/rc.d/zfs
> runs in the jail.  So, I have to log into the jail and do a 'zfs mount
> -a' after everything comes up.  Not ideal.  If there were a
> exec.postcreate directive in jail.conf that ran a command on the host
> after jail creation but before /etc/rc starts, then I could run 'zfs
> jail' before the jails init scripts are run.
> 
> Am I going about that in the wrong way?  jail.conf seems like the right
> place for it, because you want your storage working after a 'jail -rc
> git', right?
> 
> Thanks,
> 
> Marcus
> _______________________________________________
> freebsd-jail@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-jail
> To unsubscribe, send any mail to "freebsd-jail-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e684c7f412b74e203edc765c5c1406f4>