LinuxCommandLibrary

zfs

Manage ZFS storage pools and datasets

TLDR

List all available zfs filesystems

$ zfs list
copy

Create a new ZFS filesystem
$ zfs create [pool_name/filesystem_name]
copy

Delete a ZFS filesystem
$ zfs destroy [pool_name/filesystem_name]
copy

Create a Snapshot of a ZFS filesystem
$ zfs snapshot [pool_name/filesystem_name]@[snapshot_name]
copy

Enable compression on a filesystem
$ zfs set compression=on [pool_name/filesystem_name]
copy

Change mountpoint for a filesystem
$ zfs set mountpoint=/[path/to/mount_point] [pool_name/filesystem_name]
copy

SYNOPSIS

zfs [options] subcommand [subcommand-options] [arguments]

Examples:
zfs create pool/dataset_name
zfs list pool/dataset_name
zfs destroy pool/dataset_name
zfs snapshot pool/dataset_name@snapshot_name
zfs send pool/dataset_name@snapshot_name | ssh remote_host zfs receive remote_pool

PARAMETERS

create dataset
    Creates a new ZFS dataset (filesystem or volume) within a specified pool or parent dataset.

destroy dataset | snapshot
    Destroys the specified dataset or snapshot, permanently removing its data. Use with extreme caution.

list [-t type] [-r] [-o properties]
    Lists ZFS datasets and their properties. Can be filtered by type or display specific properties.

snapshot dataset@snapshot
    Creates a read-only snapshot of a dataset at a specific point in time. Snapshots are very efficient.

rollback dataset@snapshot
    Reverts a dataset to a previous state defined by a snapshot, destroying any data created after the snapshot.

send snapshot
    Generates a stream representation of a ZFS snapshot, typically used for replication or backup.

receive pool | dataset
    Receives a ZFS stream, typically from zfs send, to recreate or update a dataset on the receiving system.

set property=value dataset
    Sets a ZFS property on a dataset (e.g., compression, quota, mountpoint).

get [-r] [-p] [all | property] dataset
    Retrieves the value of ZFS properties for a dataset or all datasets.

clone snapshot dataset
    Creates a writable clone of a read-only snapshot. Clones are initially space-efficient.

rename old_name new_name
    Renames a ZFS dataset or snapshot.

hold tag snapshot
    Places a user-defined hold on a snapshot, preventing it from being destroyed until released.

release tag snapshot
    Removes a user-defined hold from a snapshot.

diff snapshot_A snapshot_B | snapshot_A dataset
    Displays the differences between a snapshot and its current state or another snapshot.

DESCRIPTION

ZFS is an advanced filesystem and logical volume manager known for its robust data integrity, massive scalability, and powerful features like snapshots, clones, and integrated RAID-Z. The zfs command is the primary tool used to interact with ZFS filesystems (also known as datasets), manage their properties, create and destroy snapshots, and perform replication operations.

It allows administrators to create, manage, and inspect the hierarchical structure of ZFS datasets, which can represent filesystems, volumes (block devices), or zvols. With zfs, users can control various aspects of their data storage, including compression, deduplication, quotas, and access control lists, making it a comprehensive solution for enterprise-grade storage management.

CAVEATS

  • zfs operations often require root privileges or membership in a privileged group.
  • The destroy subcommand is irreversible and can lead to immediate data loss if used incorrectly. Always double-check the target dataset.
  • ZFS datasets typically manage their own mounting; manual mount commands are usually unnecessary and can conflict with ZFS's auto-mounting.
  • While powerful, ZFS has a steep learning curve due to its extensive features and property system.
  • Performance tuning and optimal configuration can be complex and workload-dependent.

ZFS PROPERTIES

ZFS datasets have numerous configurable properties (e.g., compression, dedup, quota, mountpoint). These properties can be inherited from parent datasets and control various aspects of data storage and behavior. They are managed using the zfs set and zfs get subcommands.

SNAPSHOTS AND CLONES

ZFS offers highly efficient snapshots, which are read-only copies of a dataset at a specific point in time, consuming virtually no extra space initially. From snapshots, writable clones can be created. This feature is invaluable for backups, testing environments, and data versioning.

REPLICATION WITH SEND/RECEIVE

The zfs send and zfs receive subcommands enable powerful and efficient data replication. They can send incremental or full snapshots of datasets over a network, making them ideal for offsite backups, disaster recovery, and migrating ZFS data between systems.

HIERARCHICAL DESIGN

ZFS datasets are organized hierarchically, allowing for nested filesystems. Properties can be inherited down the hierarchy, simplifying management and enabling fine-grained control over different parts of your storage.

HISTORY

ZFS was originally designed and implemented by Sun Microsystems (now Oracle) for its Solaris operating system, with the first version released in 2005. It was innovative for its features like copy-on-write, end-to-end data integrity, and pooled storage. After Sun's acquisition by Oracle, the open-source development of ZFS continued under the OpenSolaris project. The Linux port, initially known as ZFS on Linux (ZoL), began in 2010, aiming to bring ZFS's robust capabilities to the Linux ecosystem. This project eventually became a part of the broader OpenZFS initiative, which unites various open-source ZFS implementations to ensure compatibility and foster collaborative development across different operating systems like Linux, FreeBSD, macOS, and Windows.

SEE ALSO

zpool(8): Manages ZFS storage pools, which are the underlying storage for ZFS datasets. This is the companion command to zfs., zdb(8): A ZFS diagnostic and debugging utility, typically used for advanced troubleshooting., mount(8): Though ZFS datasets auto-mount, mount can be used to manually mount if the mountpoint property is set to legacy., df(1): Can be used to view space usage of mounted ZFS filesystems.

Copied to clipboard