File:  [NetBSD Developer Wiki] / wikisrc / zfs.mdwn
Revision 1.31: download - view: text, annotated - select for diffs
Sun Feb 14 15:07:29 2021 UTC (23 months, 3 weeks ago) by gdt
Branches: MAIN
CVS tags: HEAD
zfs: update NFS

    1: # ZFS on NetBSD
    3: This page attempts to do two things: provide enough orientation and
    4: pointers to standard ZFS documentation for NetBSD users who are new to
    5: ZFS, and to describe NetBSD-specific ZFS information.  It is
    6: emphatically not a tutorial or an introduction to ZFS.
    8: Many things are marked with \todo because they need a better
    9: explanation, and some have question marks
   11: # Documentation Pointers
   13: See the man pages for zfs(8) and zpool(8).
   15:   - [OpenZFS Documentation](
   16:   - [OpenZFS admin docs index page](
   17:   - [FreeBSD Handbook ZFS Chapter](
   18:   - [Oracle ZFS Administration Manual](
   19:   - [Wikipedia](
   21: # Status of ZFS in NetBSD
   23: ## NetBSD 8
   25: NetBSD 8 has an old version of ZFS, and it is not recommended for use
   26: at all.  There is no evidence that anyone is interested in helping
   27: with ZFS on 8.  Those wishing to use ZFS on NetBSD 8 should therefore
   28: update to NetBSD 9.
   30: ## NetBSD 9
   32: NetBSD-9 has ZFS that is considered to work well.  There have been
   33: fixes since 9.0_RELEASE.  As always, people running NetBSD 9 are
   34: likely best served by the most recent version of the netbsd-9 stable
   35: branch.  As of 2021-02, ZFS in the NetBSD 9.1 release is very close to
   36: netbsd-9.
   38: ## NetBSD-current
   40: NetBSD-current (as of 2021-02) has similar ZFS code to 9.
   42: There is initial support for [[ZFS root|wiki/RootOnZFS]], via booting from
   43: ffs and pivoting.
   45: ## NetBSD/xen special issues
   47: In NetBSD-9, MAXPHYS is 64KB in most places, but because of xbd(4) it
   48: is set to 32KB for XEN kernels.  Thus the standard zfs kernel modules
   49: do not work under xen.  In NetBSD-current, xbd(4) supports 64 KB
   50: MAXPHYS and this is no longer an issue.
   52: Xen and zfs on current are reported to work well together, as of 2021-02.
   54: ## Architectures
   56: Most people seem to be using amd64.
   58: To build zfs, one puts MKZFS=yes in mk.conf.  This is default on amd64
   59: and aarch64 on netbsd-9.  In current, it is also default on sparc64.
   61: More or less, zfs can be enabled on an architecture when it is known
   62: to build and run reliably.  (Of course, users are welcome to build it
   63: and report.)
   65: # Quick Start
   67: See the [FreeBSD Quickstart
   68: Guide](; only
   69: the first item is NetBSD specific.
   71:   - Put zfs=YES in rc.conf.
   73:   - Create a pool as "zpool create pool1 /dev/dk0".
   75:   - df and see /pool1
   77:   - Create a filesystem mounted on /n0 as "zfs create -o
   78:     mountpoint=/n0 pool1/n0".
   80:   - Go back and read the documentation and start over.
   82: # NetBSD-specific information
   84: ## rc.conf
   86: The main configuration is to put zfs=YES in rc.conf, so that the rc.d
   87: scripts bring up ZFS and mount ZFS file systems.
   89: ## pool locations
   91: One can add disks or parts of disks into pools.  Methods of specifying
   92: areas to be included include:
   94:   - entire disks (e.g., /dev/wd0d on amd64, or /dev/wd0 which has the same major/minor)
   95:   - disklabel partitions (e.g., /dev/sd0e)
   96:   - wedges (e.g., /dev/dk0)
   98: ## mount order
  100: NetBSD 9 mounts other file systems and then ZFS file systems.  This can
  101: be a problem if /usr/pkgsrc is on ZFS and /usr/pkgsrc/distfiles is on
  102: NFS.  A workaround is to use noauto and do the mounts in
  103: /etc/rc.local.
  105: NetBSD current after 20200301 mounts ZFS first.  The same issues and
  106: workarounds apply in different circumstances.
  108: ## NFS
  110: zfs filesystems can be exported via NFS, simply by placing them in
  111: /etc/exports like any other filesystem.
  113: The "zfs share" command adds a line for each filesystem with the
  114: sharenfs property set to /etc/zfs/exports, and "zfs unshare" removes
  115: it.  \todo Explain if /etc/zfs/exports is used and whether this makes
  116: any sense on NetBSD.
  118: On current as of 20210214, a remote mkdir of a filesystem mounted via
  119: -maproot=0:10 causes a kernel NULL pointer dereference.  This is now
  120: understood and expected to be fixed very soon.  See
  121: [misc/55042](
  123: ## zvol
  125: Within a ZFS pool, the standard approach is to have file systems, but
  126: one can also create a zvol, which is a block device of a certain size.
  128: \todo The zvol will appear as /dev/???? and can be used in many
  129: respects like a slice.  However, the system will not read disklabels
  130: and gpt labels from a zvol; in this respect it is more like a disklabel
  131: partition or wedge than a disk drive.
  133: \todo Explain that one can export a zvol via iscsi.
  135: \todo Explain if one can swap on a zvol.
  137: \todo Explain that one can use ccd to create a normal-looking disk
  138: from a zvol.  This allows reading a GPT label from the zvol, which is
  139: useful in case the zvol had been exported via iscsi and some other
  140: system created a label.
  142: # Memory usage
  144: Basically, ZFS uses lots of memory and most people run it on systems
  145: with large amounts of memory.  NetBSD works well on systems with
  146: comparatively small amounts of memory.  So a natural question is how
  147: well ZFS works on one's VAX with 2M of RAM :-) More seriously, one
  148: might ask if it is reasonable to run ZFS on a RPI3 with 1G of RAM, or
  149: if it is reasonable on a system with 4G.
  151: The prevailing wisdom is more or less that ZFS consumes 1G plus 1G per
  152: 1T of disk.  32-bit architectures are viewed as too small to run ZFS.
  154: Besides RAM, zfs requires that architecture kernel stack size is at
  155: least 12KB or more -- some operations cause stack overflow with 8KB
  156: kernel stack. On NetBSD, the architectures with 16KB kernel stack are
  157: amd64, sparc64, powerpc, and experimental ia64, hppa. mac68k and sh3
  158: have 12KB kernel stack. All others use only 8KB stack, which is not
  159: enough to run zfs.
  161: NetBSD has many statistics provided via sysctl; see "sysctl
  162: kstat.zfs".
  164: FreeBSD has tunables that NetBSD does not seem to have, described in
  165: [FreeBSD Handbook ZFS Advanced
  166: section](
  168: # Interoperability with other systems
  170: Modern ZFS uses pool version 5000 and feature flags.
  172: It is in general possible to export a pool and them import the pool on
  173: some other system, as long as the other system supports all the used
  174: features.
  176: \todo Explain how to do this and what is known to work.
  178: \todo Explain feature flags relationship to FreeBSD, Linux, iIllumos,
  179: macOS.
  181: # Sources of ZFS code
  183: Currently, there are multiple ZFS projects and codebases:
  185:   - [OpenZFS](
  186:   - [openzfs repository](
  187:   - [zfsonlinux](
  188:   - [OpenZFS on OS X ]( [repo](
  189:   - proprietary ZFS in Solaris (not relevant in open source)
  190:   - ZFS as released under the CDDL (common ancestor, now of historical interest)
  192: OpenZFS is a coordinating project to align open ZFS codebases.  There
  193: is a notion of a shared core codebase and OS-specific adaptation code.
  195:   - [zfsonlinux relationship to OpenZFS](
  196:   - FreeBSD more or less imports code from openzfs and pushes back fixes. \todo Verify this.
  197:   - NetBSD has imported code from FreeBSD.
  198:   - The status of ZFS on macOS is unclear (2021-02).

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb