Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 May 2012 07:54:00 +0100
From:      Matthew Seaman <matthew@FreeBSD.org>
To:        Peter Jeremy <peterjeremy@acm.org>
Cc:        freebsd-fs@FreeBSD.org
Subject:   Re: ZFS with multiple boot/root pools
Message-ID:  <4F9F8888.3030104@FreeBSD.org>
In-Reply-To: <20120430210711.GA50280@server.vk2pj.dyndns.org>
References:  <20120430210711.GA50280@server.vk2pj.dyndns.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig9895976D0FC0F79BE8893513
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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.

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.

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

in zpool2/

zpool2	/		zfs	rw	0	0
zpool1	/ROOT/zpool1	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

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.

zpool2 will be mounted at /ROOT/zpool2 as defined in the zpool2
settings.  zpool2/usr will be mounted at /ROOT/zpool2/usr etc. etc.  To
flip to mounting the other zpool at the root, you just need to tell the
boot loader to use the other zpool. There is no need to put anything
into /etc/fstab in this case.

Apart from the wrinkle of having two different zpools, this is
essentially how ZFS boot environments work.  You should be able to adapt
one or other of the various recipes for using boot environments on the
net to suit.  I have some notes at
http://www.infracaninophile.co.uk/articles/install-on-zfs/ but there are
several other treatments around.

	Cheers,

	Matthew

[*] Use 'zfs inherit mountpoint zpool/whatever' to reset to this default
behaviour if needed.

--=20
Dr Matthew J Seaman MA, D.Phil.
PGP: http://www.infracaninophile.co.uk/pgpkey



--------------enig9895976D0FC0F79BE8893513
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+fiI8ACgkQ8Mjk52CukIwmYQCgkYaMSEogmR2U+/bNn2g+9JYQ
szcAn1mM7HtkkwczHv0YfCU689B74j1Q
=Wvtu
-----END PGP SIGNATURE-----

--------------enig9895976D0FC0F79BE8893513--



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