4 .\" The contents of this file are subject to the terms of the
5 .\" Common Development and Distribution License (the "License").
6 .\" You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 .\" or http://www.opensolaris.org/os/licensing.
10 .\" See the License for the specific language governing permissions
11 .\" and limitations under the License.
13 .\" When distributing Covered Code, include this CDDL HEADER in each
14 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 .\" If applicable, add the following below this CDDL HEADER, with the
16 .\" fields enclosed by brackets "[]" replaced with your own identifying
17 .\" information: Portions Copyright [yyyy] [name of copyright owner]
21 .\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
22 .\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
23 .\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
24 .\" Copyright (c) 2011, Pawel Jakub Dawidek <pjd@FreeBSD.org>
25 .\" Copyright (c) 2012, Glen Barber <gjb@FreeBSD.org>
26 .\" Copyright (c) 2012, Bryan Drewery <bdrewery@FreeBSD.org>
27 .\" Copyright (c) 2013, Steven Hartland <smh@FreeBSD.org>
28 .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
29 .\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
30 .\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
31 .\" Copyright (c) 2014 Integros [integros.com]
32 .\" Copyright (c) 2014, Xin LI <delphij@FreeBSD.org>
33 .\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved.
34 .\" Copyright (c) 2016 Nexenta Systems, Inc. All Rights Reserved.
35 .\" Copyright 2019 Richard Laager. All rights reserved.
36 .\" Copyright 2018 Nexenta Systems, Inc.
37 .\" Copyright 2019 Joyent, Inc.
45 .Nd configure ZFS datasets
58 command configures ZFS datasets within a ZFS storage pool, as described in
60 A dataset is identified by a unique path within the ZFS namespace.
62 .Dl pool/{filesystem,volume,snapshot}
64 where the maximum length of a dataset name is
65 .Sy MAXNAMELEN Pq 256B
66 and the maximum amount of nesting allowed in a path is 50 levels deep.
68 A dataset can be one of the following:
69 .Bl -tag -offset Ds -width "file system"
71 Can be mounted within the standard system namespace and behaves like other file
73 While ZFS file systems are designed to be POSIX-compliant, known issues exist
74 that prevent compliance in some cases.
75 Applications that depend on standards conformance might fail due to non-standard
76 behavior when checking file system free space.
78 A logical volume exported as a raw or block device.
79 This type of dataset should only be used when a block device is required.
80 File systems are typically used in most environments.
82 A read-only version of a file system or volume at a given point in time.
84 .Ar filesystem Ns @ Ns Ar name
86 .Ar volume Ns @ Ns Ar name .
90 but without the hold on on-disk data.
91 It can be used as the source of a send (but not for a receive).
93 .Ar filesystem Ns # Ns Ar name
95 .Ar volume Ns # Ns Ar name .
103 Properties are divided into two types: native properties and user-defined
106 Native properties either export internal statistics or control ZFS behavior.
107 In addition, native properties are either editable or read-only.
108 User properties have no effect on ZFS behavior, but you can use them to annotate
109 datasets in a way that is meaningful in your environment.
110 For more information about properties, see
116 feature allows for the creation of encrypted filesystems and volumes.
117 ZFS will encrypt file and zvol data, file attributes, ACLs, permission bits,
118 directory listings, FUID mappings, and
119 .Sy userused Ns / Ns Sy groupused Ns / Ns Sy projectused
121 For an overview of encryption, see
125 All subcommands that modify state are logged persistently to the pool in their
129 Displays a help message.
138 Displays the software version of the
140 userland utility and the zfs kernel module.
143 .Ss Dataset Management
146 Lists the property information for the given datasets in tabular form.
148 Creates a new ZFS file system or volume.
150 Destroys the given dataset(s), snapshot(s), or bookmark.
152 Renames the given dataset (filesystem or snapshot).
154 Manage upgrading the on-disk version of filesystems.
159 .It Xr zfs-snapshot 8
160 Creates snapshots with the given names.
161 .It Xr zfs-rollback 8
162 Roll back the given dataset to a previous snapshot.
163 .It Xr zfs-hold 8 Ns / Ns Xr zfs-release 8
164 Add or remove a hold reference to the specified snapshot or snapshots.
165 If a hold exists on a snapshot, attempts to destroy that snapshot by using the
170 Display the difference between a snapshot of a given filesystem and another
171 snapshot of that filesystem from a later time or the current contents of the
178 Creates a clone of the given snapshot.
180 Promotes a clone file system to no longer be dependent on its
188 Generate a send stream, which may be of a filesystem, and may be incremental
191 Creates a snapshot whose contents are as specified in the stream provided on
193 If a full stream is received, then a new file system is created as well.
194 Streams are created using the
196 subcommand, which by default creates a full stream.
197 .It Xr zfs-bookmark 8
198 Creates a new bookmark of the given snapshot or bookmark.
199 Bookmarks mark the point in time when the snapshot was created, and can be used
200 as the incremental source for a
204 Generate a new redaction bookmark.
205 This feature can be used to allow clones of a filesystem to be made available on
206 a remote system, in the case where their parent need not (or needs to not) be
213 Displays properties for the given datasets.
215 Sets the property or list of properties to the given value(s) for each dataset.
217 Clears the specified property, causing it to be inherited from an ancestor,
218 restored to default if no ancestor has the property set, or with the
220 option reverted to the received value if one exists.
225 .It Xr zfs-userspace 8 Ns / Ns Xr zfs-groupspace 8 Ns / Ns Xr zfs-projectspace 8
226 Displays space consumed by, and quotas on, each user, group, or project
227 in the specified filesystem or snapshot.
229 List, set, or clear project ID and/or inherit flag on the file(s) or directories.
235 Displays all ZFS file systems currently mounted, or mount ZFS filesystem
236 on a path described by its
240 Unmounts currently mounted ZFS file systems.
246 Shares available ZFS file systems.
248 Unshares currently shared ZFS file systems.
251 .Ss Delegated Administration
254 Delegate permissions on the specified filesystem or volume.
256 Remove delegated permissions on the specified filesystem or volume.
261 .It Xr zfs-change-key 8
262 Add or change an encryption key on the specified dataset.
263 .It Xr zfs-load-key 8
264 Load the key for the specified encrypted dataset, enabling access.
265 .It Xr zfs-unload-key 8
266 Unload a key for the specified dataset, removing the ability to access the dataset.
272 Execute ZFS administrative operations
273 programmatically via a Lua script-language channel program.
279 Attaches a filesystem to a jail.
281 Detaches a filesystem from a jail.
287 Wait for background activity in a filesystem to complete.
297 if an error occurs, and
299 if invalid command line options were specified.
304 .It Sy Example 1 : No Creating a ZFS File System Hierarchy
305 The following commands create a file system named
307 and a file system named
311 is set for the parent file system, and is automatically inherited by the child
313 .Dl # Nm zfs Cm create Ar pool/home
314 .Dl # Nm zfs Cm set Sy mountpoint Ns = Ns Ar /export/home pool/home
315 .Dl # Nm zfs Cm create Ar pool/home/bob
317 .It Sy Example 2 : No Creating a ZFS Snapshot
318 The following command creates a snapshot named
320 This snapshot is mounted on demand in the
322 directory at the root of the
325 .Dl # Nm zfs Cm snapshot Ar pool/home/bob Ns @ Ns Ar yesterday
327 .It Sy Example 3 : No Creating and Destroying Multiple Snapshots
328 The following command creates snapshots named
329 .Ar yesterday No of Ar pool/home
330 and all of its descendent file systems.
331 Each snapshot is mounted on demand in the
333 directory at the root of its file system.
334 The second command destroys the newly created snapshots.
335 .Dl # Nm zfs Cm snapshot Fl r Ar pool/home Ns @ Ns Ar yesterday
336 .Dl # Nm zfs Cm destroy Fl r Ar pool/home Ns @ Ns Ar yesterday
338 .It Sy Example 4 : No Disabling and Enabling File System Compression
339 The following command disables the
341 property for all file systems under
343 The next command explicitly enables
347 .Dl # Nm zfs Cm set Sy compression Ns = Ns Sy off Ar pool/home
348 .Dl # Nm zfs Cm set Sy compression Ns = Ns Sy on Ar pool/home/anne
350 .It Sy Example 5 : No Listing ZFS Datasets
351 The following command lists all active file systems and volumes in the system.
352 Snapshots are displayed if
353 .Sy listsnaps Ns = Ns Sy on .
358 for more information on pool properties.
359 .Bd -literal -compact -offset Ds
361 NAME USED AVAIL REFER MOUNTPOINT
362 pool 450K 457G 18K /pool
363 pool/home 315K 457G 21K /export/home
364 pool/home/anne 18K 457G 18K /export/home/anne
365 pool/home/bob 276K 457G 276K /export/home/bob
368 .It Sy Example 6 : No Setting a Quota on a ZFS File System
369 The following command sets a quota of 50 Gbytes for
371 .Dl # Nm zfs Cm set Sy quota Ns = Ns Ar 50G pool/home/bob
373 .It Sy Example 7 : No Listing ZFS Properties
374 The following command lists all properties for
376 .Bd -literal -compact -offset Ds
377 .No # Nm zfs Cm get Sy all Ar pool/home/bob
378 NAME PROPERTY VALUE SOURCE
379 pool/home/bob type filesystem -
380 pool/home/bob creation Tue Jul 21 15:53 2009 -
381 pool/home/bob used 21K -
382 pool/home/bob available 20.0G -
383 pool/home/bob referenced 21K -
384 pool/home/bob compressratio 1.00x -
385 pool/home/bob mounted yes -
386 pool/home/bob quota 20G local
387 pool/home/bob reservation none default
388 pool/home/bob recordsize 128K default
389 pool/home/bob mountpoint /pool/home/bob default
390 pool/home/bob sharenfs off default
391 pool/home/bob checksum on default
392 pool/home/bob compression on local
393 pool/home/bob atime on default
394 pool/home/bob devices on default
395 pool/home/bob exec on default
396 pool/home/bob setuid on default
397 pool/home/bob readonly off default
398 pool/home/bob zoned off default
399 pool/home/bob snapdir hidden default
400 pool/home/bob acltype off default
401 pool/home/bob aclmode discard default
402 pool/home/bob aclinherit restricted default
403 pool/home/bob canmount on default
404 pool/home/bob xattr on default
405 pool/home/bob copies 1 default
406 pool/home/bob version 4 -
407 pool/home/bob utf8only off -
408 pool/home/bob normalization none -
409 pool/home/bob casesensitivity sensitive -
410 pool/home/bob vscan off default
411 pool/home/bob nbmand off default
412 pool/home/bob sharesmb off default
413 pool/home/bob refquota none default
414 pool/home/bob refreservation none default
415 pool/home/bob primarycache all default
416 pool/home/bob secondarycache all default
417 pool/home/bob usedbysnapshots 0 -
418 pool/home/bob usedbydataset 21K -
419 pool/home/bob usedbychildren 0 -
420 pool/home/bob usedbyrefreservation 0 -
423 The following command gets a single property value:
424 .Bd -literal -compact -offset Ds
425 .No # Nm zfs Cm get Fl H o Sy value compression Ar pool/home/bob
429 The following command lists all properties with local settings for
431 .Bd -literal -compact -offset Ds
432 .No # Nm zfs Cm get Fl r s Sy local Fl o Sy name , Ns Sy property , Ns Sy value all Ar pool/home/bob
434 pool/home/bob quota 20G
435 pool/home/bob compression on
438 .It Sy Example 8 : No Rolling Back a ZFS File System
439 The following command reverts the contents of
441 to the snapshot named
443 deleting all intermediate snapshots:
444 .Dl # Nm zfs Cm rollback Fl r Ar pool/home/anne Ns @ Ns Ar yesterday
446 .It Sy Example 9 : No Creating a ZFS Clone
447 The following command creates a writable file system whose initial contents are
449 .Ar pool/home/bob@yesterday .
450 .Dl # Nm zfs Cm clone Ar pool/home/bob@yesterday pool/clone
452 .It Sy Example 10 : No Promoting a ZFS Clone
453 The following commands illustrate how to test out changes to a file system, and
454 then replace the original file system with the changed one, using clones, clone
455 promotion, and renaming:
456 .Bd -literal -compact -offset Ds
457 .No # Nm zfs Cm create Ar pool/project/production
458 populate /pool/project/production with data
459 .No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today
460 .No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta
461 make changes to /pool/project/beta and test them
462 .No # Nm zfs Cm promote Ar pool/project/beta
463 .No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy
464 .No # Nm zfs Cm rename Ar pool/project/beta pool/project/production
465 once the legacy version is no longer needed, it can be destroyed
466 .No # Nm zfs Cm destroy Ar pool/project/legacy
469 .It Sy Example 11 : No Inheriting ZFS Properties
470 The following command causes
471 .Ar pool/home/bob No and Ar pool/home/anne
474 property from their parent.
475 .Dl # Nm zfs Cm inherit Sy checksum Ar pool/home/bob pool/home/anne
477 .It Sy Example 12 : No Remotely Replicating ZFS Data
478 The following commands send a full stream and then an incremental stream to a
479 remote machine, restoring them into
480 .Em poolB/received/fs@a
482 .Em poolB/received/fs@b ,
485 must contain the file system
487 and must not initially contain
488 .Em poolB/received/fs .
489 .Bd -literal -compact -offset Ds
490 .No # Nm zfs Cm send Ar pool/fs@a |
491 .No " " Nm ssh Ar host Nm zfs Cm receive Ar poolB/received/fs Ns @ Ns Ar a
492 .No # Nm zfs Cm send Fl i Ar a pool/fs@b |
493 .No " " Nm ssh Ar host Nm zfs Cm receive Ar poolB/received/fs
496 .It Sy Example 13 : No Using the Nm zfs Cm receive Fl d No Option
497 The following command sends a full stream of
498 .Ar poolA/fsA/fsB@snap
499 to a remote machine, receiving it into
500 .Ar poolB/received/fsA/fsB@snap .
503 portion of the received snapshot's name is determined from the name of the sent
506 must contain the file system
509 .Ar poolB/received/fsA
510 does not exist, it is created as an empty file system.
511 .Bd -literal -compact -offset Ds
512 .No # Nm zfs Cm send Ar poolA/fsA/fsB@snap |
513 .No " " Nm ssh Ar host Nm zfs Cm receive Fl d Ar poolB/received
516 .It Sy Example 14 : No Setting User Properties
517 The following example sets the user-defined
518 .Ar com.example : Ns Ar department
519 property for a dataset:
520 .Dl # Nm zfs Cm set Ar com.example : Ns Ar department Ns = Ns Ar 12345 tank/accounting
522 .It Sy Example 15 : No Performing a Rolling Snapshot
523 The following example shows how to maintain a history of snapshots with a
524 consistent naming scheme.
525 To keep a week's worth of snapshots, the user destroys the oldest snapshot,
526 renames the remaining snapshots, and then creates a new snapshot, as follows:
527 .Bd -literal -compact -offset Ds
528 .No # Nm zfs Cm destroy Fl r Ar pool/users@7daysago
529 .No # Nm zfs Cm rename Fl r Ar pool/users@6daysago No @ Ns Ar 7daysago
530 .No # Nm zfs Cm rename Fl r Ar pool/users@5daysago No @ Ns Ar 6daysago
531 .No # Nm zfs Cm rename Fl r Ar pool/users@4daysago No @ Ns Ar 5daysago
532 .No # Nm zfs Cm rename Fl r Ar pool/users@3daysago No @ Ns Ar 4daysago
533 .No # Nm zfs Cm rename Fl r Ar pool/users@2daysago No @ Ns Ar 3daysago
534 .No # Nm zfs Cm rename Fl r Ar pool/users@yesterday No @ Ns Ar 2daysago
535 .No # Nm zfs Cm rename Fl r Ar pool/users@today No @ Ns Ar yesterday
536 .No # Nm zfs Cm snapshot Fl r Ar pool/users Ns @ Ns Ar today
539 .It Sy Example 16 : No Setting sharenfs Property Options on a ZFS File System
540 The following commands show how to set
542 property options to enable read-write
543 access for a set of IP addresses and to enable root access for system
548 .Dl # Nm zfs Cm set Sy sharenfs Ns = Ns ' Ns Ar rw Ns =@123.123.0.0/16,root= Ns Ar neo Ns ' tank/home
550 If you are using DNS for host name resolution,
551 specify the fully-qualified hostname.
553 .It Sy Example 17 : No Delegating ZFS Administration Permissions on a ZFS Dataset
554 The following example shows how to set permissions so that user
556 can create, destroy, mount, and take snapshots on
561 .Bd -literal -compact -offset Ds
562 .No # Nm zfs Cm allow Sy cindys create , Ns Sy destroy , Ns Sy mount , Ns Sy snapshot Ar tank/cindys
563 .No # Nm zfs Cm allow Ar tank/cindys
564 ---- Permissions on tank/cindys --------------------------------------
565 Local+Descendent permissions:
566 user cindys create,destroy,mount,snapshot
571 mount point permission is set to 755 by default, user
573 will be unable to mount file systems under
575 Add an ACE similar to the following syntax to provide mount point access:
576 .Dl # Cm chmod No A+user: Ns Ar cindys Ns :add_subdirectory:allow Ar /tank/cindys
578 .It Sy Example 18 : No Delegating Create Time Permissions on a ZFS Dataset
579 The following example shows how to grant anyone in the group
581 to create file systems in
583 This syntax also allows staff members to destroy their own file systems, but not
584 destroy anyone else's file system.
588 .Bd -literal -compact -offset Ds
589 .No # Nm zfs Cm allow Ar staff Sy create , Ns Sy mount Ar tank/users
590 .No # Nm zfs Cm allow Fl c Sy destroy Ar tank/users
591 .No # Nm zfs Cm allow Ar tank/users
592 ---- Permissions on tank/users ---------------------------------------
595 Local+Descendent permissions:
596 group staff create,mount
599 .It Sy Example 19 : No Defining and Granting a Permission Set on a ZFS Dataset
600 The following example shows how to define and grant a permission set on the
606 .Bd -literal -compact -offset Ds
607 .No # Nm zfs Cm allow Fl s No @ Ns Ar pset Sy create , Ns Sy destroy , Ns Sy snapshot , Ns Sy mount Ar tank/users
608 .No # Nm zfs Cm allow staff No @ Ns Ar pset tank/users
609 .No # Nm zfs Cm allow Ar tank/users
610 ---- Permissions on tank/users ---------------------------------------
612 @pset create,destroy,mount,snapshot
613 Local+Descendent permissions:
617 .It Sy Example 20 : No Delegating Property Permissions on a ZFS Dataset
618 The following example shows to grant the ability to set quotas and reservations
625 .Bd -literal -compact -offset Ds
626 .No # Nm zfs Cm allow Ar cindys Sy quota , Ns Sy reservation Ar users/home
627 .No # Nm zfs Cm allow Ar users/home
628 ---- Permissions on users/home ---------------------------------------
629 Local+Descendent permissions:
630 user cindys quota,reservation
631 cindys% zfs set quota=10G users/home/marks
632 cindys% zfs get quota users/home/marks
633 NAME PROPERTY VALUE SOURCE
634 users/home/marks quota 10G local
637 .It Sy Example 21 : No Removing ZFS Delegated Permissions on a ZFS Dataset
638 The following example shows how to remove the snapshot permission from the
646 .Bd -literal -compact -offset Ds
647 .No # Nm zfs Cm unallow Ar staff Sy snapshot Ar tank/users
648 .No # Nm zfs Cm allow Ar tank/users
649 ---- Permissions on tank/users ---------------------------------------
651 @pset create,destroy,mount,snapshot
652 Local+Descendent permissions:
656 .It Sy Example 22 : No Showing the differences between a snapshot and a ZFS Dataset
657 The following example shows how to see what has changed between a prior
658 snapshot of a ZFS dataset and its current state.
661 option is used to indicate type information for the files affected.
662 .Bd -literal -compact -offset Ds
663 .No # Nm zfs Cm diff Fl F Ar tank/test@before tank/test
665 M F /tank/test/linked (+1)
666 R F /tank/test/oldname -> /tank/test/newname
667 - F /tank/test/deleted
668 + F /tank/test/created
669 M F /tank/test/modified
672 .It Sy Example 23 : No Creating a bookmark
673 The following example create a bookmark to a snapshot.
674 This bookmark can then be used instead of snapshot in send streams.
675 .Dl # Nm zfs Cm bookmark Ar rpool Ns @ Ns Ar snapshot rpool Ns # Ns Ar bookmark
677 .It Sy Example 24 : No Setting Sy sharesmb No Property Options on a ZFS File System
678 The following example show how to share SMB filesystem through ZFS.
679 Note that a user and their password must be given.
680 .Dl # Nm smbmount Ar //127.0.0.1/share_tmp /mnt/tmp Fl o No user=workgroup/turbo,password=obrut,uid=1000
683 .Pa /etc/samba/smb.conf
684 configuration is required, as follows.
686 Samba will need to bind to the loopback interface for the ZFS utilities to
687 communicate with Samba.
688 This is the default behavior for most Linux distributions.
690 Samba must be able to authenticate a user.
691 This can be done in a number of ways
692 .Pq Xr passwd 5 , LDAP , Xr smbpasswd 5 , &c.\& .
693 How to do this is outside the scope of this document – refer to
695 for more information.
699 section for all configuration options,
700 in case you need to modify any options of the share afterwards.
701 Do note that any changes done with the
703 command will be undone if the share is ever unshared (like via a reboot).
706 .Sh ENVIRONMENT VARIABLES
707 .Bl -tag -width "ZFS_MOUNT_HELPER"
708 .It Sy ZFS_MOUNT_HELPER
713 to mount ZFS datasets.
714 This option is provided for backwards compatibility with older ZFS versions.
717 .Sh INTERFACE STABILITY
739 .Xr zfs-change-key 8 ,
745 .Xr zfs-groupspace 8 ,
754 .Xr zfs-projectspace 8 ,
767 .Xr zfs-unload-key 8 ,
771 .Xr zfs-userspace 8 ,