How allow.mount.zfs affects mountpoints for ZFS

I noticed this the other day, and thought it was interesting.

When the jailed property is set on a ZFS fileset, it affects the mountpoint within the jail.

If your jail uses allow.mount.zfs (known as allow_mount_zfs when using iocage), the mountpoints become relative to the jail.

For example, in my poudriere jail, this is what I see the main dataset:

[dan@pkg01:~] $ zfs list tank_fast/poudriere
NAME                  USED  AVAIL  REFER  MOUNTPOINT
tank_fast/poudriere  51.1G   452G    88K  /usr/local/poudriere
[dan@pkg01:~] $ 

From the host, this is what I see:

[dan@r720-01:~] $ zfs list tank_fast/poudriere
NAME                  USED  AVAIL  REFER  MOUNTPOINT
tank_fast/poudriere  51.1G   452G    88K  /usr/local/poudriere
[dan@r720-01:~] $ 

That is exactly the same thing.

Let’s look at the mountpoint within the jail:

[dan@pkg01:~] $ zfs get mountpoint tank_fast/poudriere
NAME                 PROPERTY    VALUE                 SOURCE
tank_fast/poudriere  mountpoint  /usr/local/poudriere  local

Yep, that is where is should be.

I expected the host to show the same thing, and that some magic was occurring under the hood.

Yeah, precisely the same thing on the host:

[dan@r720-01:~] $ zfs get mountpoint tank_fast/poudriere
NAME                 PROPERTY    VALUE                 SOURCE
tank_fast/poudriere  mountpoint  /usr/local/poudriere  local

So where is the magic? Something has to be mounting the filesets into the jail?

The magic isn’t in the definde mountpoints, it’s what zfs does when it performs the mount.

It can be seen here, on the host:

[dan@r720-01:~] $ zfs mount | grep tank_fast/poudriere
tank_fast/poudriere             /iocage/jails/pkg01/root/usr/local/poudriere

I have trimmed the output to include only the top level.

The path to the jail has been prepended to the mountpoint.

You can find the path with this command:

[dan@r720-01:~] $ jls -n -j 11 path
path=/iocage/jails/pkg01/root

Where 13 is the jail id of your jail.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top