Dualboot and ZFS

Matthew Seaman matthew at FreeBSD.org
Tue Jan 16 12:15:43 UTC 2018

On 16/01/2018 11:28, Victor Sudakov wrote:
> Do you know how to create a beadm-friendly zroot manually (like the one
> created automatically by bsdinstall)? 

This is not particularly difficult.  First, you need to consider the
standard directory structure and mentally divide the ZFSes containing
this content into two classes:

   * The Kernel, kernel modules, binaries, shared libraries, application
     and system configuration files that would be affected by a system

   * Working data, temporary files, documents, log files etc. which
     would not be affected by a system upgrade.

The first type should be part of the boot environment files, the second
type outside it.  If necessary you may need to create additional ZFSes
to divide content appropriately.

For my systems this works out to a breakdown like this:

   / --> BE
     (This includes /boot, /etc)

   /tmp --> not.  Not a ZFS.  I usually use a tmpfs for /tmp
   /dev --> not.  Not a ZFS.  Uses devfs

   /home --> not.  I generally remove the symlink from /usr/home and
                   make /home a first class ZFS directly.

   /usr --> BE
   /usr/local --> BE
   /usr/obj --> BE
   /usr/src --> BE
   /usr/ports --> not
   /usr/ports/distfiles --> not

   /var --> BE
   /var/crash --> not
   /var/db --> BE
   /var/db/pkg --> BE
   /var/db/postgres --> not
   /var/empty --> not
   /var/log --> not
   /var/run --> not
   /var/tmp --> not
   /var/mail --> not

Plus various other ZFSes for jails and poudriere etc.   Now, assuming
your root zpool is called zroot, and the BE name is '11.1-RELEASE-p6'
you will want to create ZFSes like so:

   ZFS                                Mountpoint        Canmount
   zroot                              /                 no
   zroot/ROOT                         /ROOT             no

   zroot/ROOT/11.1-RELEASE-p6         /                 yes
   zroot/ROOT/11.1-RELEASE-p6/usr     /usr              yes
   zroot/ROOT/11.1-RELEASE-p6/var     /var              yes
   zroot/ROOT/11.1-RELEASE-p6/var/db  /var/db           yes


   zroot/home                         /home             yes
   zroot/var                          /var              no
   zroot/var/log                      /var/log          yes
   zroot/var/db                       /var/db           no
   zroot/var/db/postgres              /var/db/postgres  yes


Note the trick of creating two different ZFSes with the same mountpoint,
where one is actually mounted and contains files, and the other is never
mounted, contains nothing and only serves to provide the inheritance of
values for child ZFSes.  This allows mounting a filesystem from outside
the BE (eg. /var/log) beneath a directory from within the BE (eg. /var)

If this seems overly complex, well, it is.  That's the price you pay for
taking the familiar Unix filesystem hierarchy and adapting it to
filesystem semantics developed decades later.  If we were starting from
scratch laying out an OS based on ZFS we'd certainly arrange things a
bit more conveniently for use with boot environments.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 992 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20180116/d0d52765/attachment.sig>

More information about the freebsd-questions mailing list