ZFS with multiple boot/root pools

Peter Jeremy peterjeremy at acm.org
Wed May 2 05:28:21 UTC 2012


On 2012-May-01 07:54:00 +0100, Matthew Seaman <matthew at FreeBSD.org> wrote:
>On 30/04/2012 22:07, Peter Jeremy wrote:
>> Can anyone suggest a way to configure a zpool or set of filesystems
>> so that they will only be mounted if the root filesystem is within
>> the zpool.
>
>Not exactly that, but this should suffice.

It sounds good but I can't make it work.

>Suppose your two pools are zpool1 and zpool2.  You have several ZFSes on
>each pool, all of which should be set to the default[*] that they are
>all mounted relative to the top level ZFS -- either zpool1/ or zpool2/
>-- so to avoid overlaps, all you need to do is mount the top level ZFS
>at a unique path.

Yep.  To go further, assume there are also zpool{1,2}/var filesystems,
one of which should be mounted as /var.  The mountpoint for zpool{1,2}/var
can be one of:
A) legacy
   This requires an entry in each /etc/fstab for /var
B) inherited
   This depends on the value of mountpoint for zpool{1,2}:
   a) legacy
      Same as (A) above.
   b) inherited
      The mountpoint will be set to /zpool{1,2}/var
   c) Set to some arbitrary value, say /foo
      The mountpoint will be set to /foo/var
C) /var
   This results is two /var filesystems unless one is marked "canmount=noauto"

>One way of doing this is to set the mountpoints for the top level
>zpool1/ and zpool2/ to legacy, and create /etc/fstab in each pool like so:
>
>in zpool1/
>
>zpool1	/		zfs	rw	0	0
>zpool2	/ROOT/zpool2	zfs	rw	0	0

Following the breakdown above, this implies I'd also need an entry in
/etc/fstab:
zpool1/var		/var	zfs	rw	0	0

>Another way of doing this is to realise that the vfs.root.mountfrom
>property in /boot/loader.conf overrides any internal settings in the
>zpools.  This means that you can set the mountpoint for zpool1/ and
>zpool2/ to some distinct values, say, /ROOT/zpool1 and /ROOT/zpool2

Whilst this overrides the mountpoint for the root filesystem, it has
no effect on other filesystems in the pool.  In particular, the
mountpoint for zpool1/var remains /zpool1/var and the "zfs mount -a"
fails because there's no /zpool1

>If vfs.root.mountfrom is set to zfs:zpool1 then that zpool will be
>mounted as the root filesystem at / and zpool1/usr, zpool1/var etc. etc.
>will all be mounted in the expected locations relative to that.

Unfortunately my experiments on a 10-current box show this doesn't
happen.  Inheriting a mountpoint means that the filesystem's
mountpoint is set to the parent's nominal mountpoint (ie zpool{1,2}),
not the actual mountpoint (ie /), with the filesystem name appended.

>Apart from the wrinkle of having two different zpools, this is
>essentially how ZFS boot environments work.

Except that beadm/manageBE does a lot of other juggling to switch
between BEs.

>http://www.infracaninophile.co.uk/articles/install-on-zfs/ but there are
>several other treatments around.

I've had a look through those notes and you are still specifying
mountpoints for (eg) zroot/ROOT/9.0-RELEASE/usr - which implies you
wind up with multiple /usr's mounted.  

-- 
Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20120502/91bcbec5/attachment.pgp


More information about the freebsd-fs mailing list