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=[/my/mount/path] [pool_name/filesystem_name]
copy

SYNOPSIS

zfs subcommand [options] dataset

PARAMETERS

create
    Creates a new ZFS dataset or volume.

destroy
    Destroys the specified ZFS dataset or volume.

snapshot
    Creates a snapshot of the specified dataset.

clone
    Creates a clone of the specified snapshot.

promote
    Promotes a clone to be the active dataset.

rollback
    Rolls back a dataset to a previous snapshot.

send
    Generates a stream representation of a dataset or snapshot. Used for replication.

receive
    Receives a stream representation and creates a ZFS dataset or snapshot.

rename
    Renames a ZFS dataset or volume.

set
    Sets a property on a ZFS dataset or volume.

get
    Gets a property on a ZFS dataset or volume.

list
    Lists ZFS datasets, volumes, and snapshots.

mount
    Mounts a ZFS dataset.

unmount
    Unmounts a ZFS dataset.

share
    Shares a ZFS dataset via NFS or SMB.

unshare
    Unshares a ZFS dataset.

upgrade
    Upgrades the ZFS pool version.

-o property=value
    Specifies a property and value to set during dataset creation.

-r
    Recursive operation (e.g., destroy all descendants).

-n
    Dry-run operation (e.g., show what would be done without actually doing it).

-v
    Verbose output.

-p
    For use with snapshots, creates intermediate datasets as necessary.

-F
    Force unmount the file system. Use with care, it can lead to data corruption.

DESCRIPTION

ZFS is a combined file system and logical volume manager designed for data integrity. It offers advanced features such as data redundancy, snapshotting, compression, and encryption. The zfs command is the primary tool for managing ZFS datasets, volumes, and pools. It allows you to create, destroy, modify, and monitor ZFS storage.
ZFS pools are created from virtual devices (vdevs), which can be physical disks, partitions, or files. Datasets within a pool can be managed independently, allowing for fine-grained control over storage resources. ZFS's copy-on-write architecture ensures data consistency, and its checksumming capabilities prevent data corruption. It's commonly used in environments where data reliability and management are critical, such as servers and storage appliances. Understanding the various options and subcommands is key to effectively utilizing ZFS's powerful features.
Improper use can result in data loss.
Consider testing configurations in a virtualized environment before deploying to production.

CAVEATS

Destroying a ZFS dataset irretrievably removes all data within it. Ensure proper backups exist before performing destructive operations. Incorrectly configuring ZFS can lead to degraded performance or data loss. It is critical to understand the implications of each parameter and property before making changes to a ZFS pool or dataset.

DATASET TYPES

ZFS supports several dataset types:
- Filesystems: General-purpose storage, like a traditional partition.
- Volumes (zvols): Block devices suitable for swap space or virtual machine disks.
- Snapshots: Read-only point-in-time copies of datasets.

COMMON PROPERTIES

Important ZFS properties include:
- compression: Enables compression (lz4 is recommended).
- atime: Controls whether access time is updated.
- recordsize: The block size used for storing data.
- mountpoint: The directory where the dataset is mounted.
- quota: Sets a maximum size for the dataset.
- reservation: Guarantees a minimum amount of space for the dataset.

DATA INTEGRITY

ZFS protects against data corruption through checksumming. Every block of data is checksummed when written. When read, the checksum is verified to ensure that the data has not been corrupted.
If corruption is detected and redundancy is available (e.g. through mirroring or RAID-Z), ZFS can automatically repair the data.

HISTORY

ZFS was originally developed by Sun Microsystems for Solaris. It was open-sourced in 2005. While Solaris is no longer actively developed, ZFS has been ported to various operating systems, including FreeBSD and Linux. Its reliability and advanced features have made it a popular choice for large-scale storage systems and data centers.
The Linux implementation has seen continuous development and improvement through community contributions.

SEE ALSO

zpool(8), mount(8), umount(8), df(1)

Copied to clipboard