zfs in jail auto mount issue

Hi Forum,

Don't know if this right place to ask, this is a question regarding to zfs in jail and auto mount.

I created a jail to install mysql database, and database data folder on zfs. So on host: I created zfs and set jailed=on.

Now I installed jail, and on host I run [cmd=]zfs jail <jid> tank/data/mysql[/cmd] to export zfs to jail, and inside jail, I run [cmd=]zfs mount -a[/cmd] and set dbdir of mysql to /mnt/tank/data/mysql. So far so good.

Now the problem is automate. I want my jail start during system boot. So db jail been added into host's /etc/rc.conf. And I need a poststart script to run [cmd=]_jail_id = $(cat /var/run/jail_db.id)[/cmd] and then [cmd=]zfs jail ${_jail_id} tank/data/mysql[/cmd]

I had to put it into poststart, because before that, there's no JID. But poststart means jail already started (include all services), and mysql already started and using /mnt/tank/data/mysql, which not a zfs mount as data dir. so /mnt/tank/data/mysql is cannot mounted in db jail.

I believe this is common usage of zfs in jail, so I must did something wrong. probably not in poststart? Any tip?

Thanks a lot

Noodle
 
Why don't you just mount it from the host? That's what I do.

Code:
root@molly:~#zfs list -r tank/FreeBSD/jails/j2
NAME                          USED  AVAIL  REFER  MOUNTPOINT
tank/FreeBSD/jails/j2        1.03G  1.27T   993M  /jails/j2
tank/FreeBSD/jails/j2/mysql  61.5M  1.27T  61.5M  /jails/j2/var/db/mysql
 
Because I want a separate filesystem for the MySQL databases. That should make updating the jail a little easier.
 
Back
Top