LinuxCommandLibrary

zpool

Manage ZFS storage pools

TLDR

Show the configuration and status of all ZFS zpools

$ zpool status
copy

Check a ZFS pool for errors (verifies the checksum of EVERY block). Very CPU and disk intensive
$ zpool scrub [pool_name]
copy

List zpools available for import
$ zpool import
copy

Import a zpool
$ zpool import [pool_name]
copy

Export a zpool (unmount all filesystems)
$ zpool export [pool_name]
copy

Show the history of all pool operations
$ zpool history [pool_name]
copy

Create a mirrored pool
$ zpool create [pool_name] mirror [disk1] [disk2] mirror [disk3] [disk4]
copy

Add a cache (L2ARC) device to a zpool
$ zpool add [pool_name] cache [cache_disk]
copy

SYNOPSIS

zpool [<options>] <command> [<command_options>] [<arguments>]

Examples:
zpool create mypool mirror /dev/sda /dev/sdb
zpool status
zpool add mypool log /dev/sdc
zpool destroy mypool

PARAMETERS

create []
    Creates a new ZFS storage pool. Specifies pool name and virtual devices (vdevs) like mirrors, RAID-Z groups, or single disks. Supports options for properties and features.

destroy
    Destroys the specified ZFS storage pool, removing all data and associated ZFS file systems. This operation is irreversible.

status []
    Displays the health and status of ZFS storage pools. Shows vdev layout, device status, errors, and ongoing operations like scrubbing or resilvering.

add []
    Adds new virtual devices (vdevs) to an existing ZFS pool. Can be used to expand capacity or add redundancy (e.g., adding a new mirror or RAID-Z group).

remove
    Removes a device or vdev from the specified pool. Limitations apply; removal is only possible for certain vdev types (e.g., spares, cache, log devices) or if sufficient redundancy exists (e.g., reducing a mirror to a single disk).

list []
    Lists configured ZFS storage pools, displaying basic information such as size, allocation, free space, and health.

iostat [] [ []]
    Displays I/O statistics for ZFS storage pools and their associated devices, useful for performance monitoring.

import [ | ]
    Imports a ZFS storage pool that was previously exported or moved to a new system. Can find pools by name or ID.

export
    Exports a ZFS storage pool, making it unavailable on the current system. Prepares the pool for transfer or shutdown.

scrub []
    Initiates or resumes a scrub operation on a ZFS pool. A scrub reads all data to verify checksums and repair any silent data corruption.

resilver
    Initiates or resumes a resilver operation on a ZFS pool. This occurs automatically when a faulted device in a redundant configuration is replaced or comes back online.

upgrade []
    Upgrades a ZFS pool to the latest supported pool version, enabling new features. This is a one-way operation and cannot be downgraded.

set =
    Sets a ZFS pool property (e.g., autoexpand, cachefile). Each property has specific values and behaviors.

get []
    Retrieves the value of a specified ZFS pool property. Can show all properties for a pool or a specific one.

DESCRIPTION

zpool is the primary command-line utility for managing ZFS storage pools. ZFS is an advanced file system and logical volume manager known for its data integrity, snapshotting, and scalability features. The zpool command allows administrators to create, destroy, extend, monitor, and manage the health of these pools. It interacts directly with the underlying storage devices (disks, partitions, files) to aggregate them into resilient and performant storage structures, such as mirrors (RAID1) or RAID-Z (similar to RAID5/6). Administrators use zpool for tasks like adding or removing devices, checking pool status and health, performing data scrubs, and upgrading pool versions. It is an indispensable tool for anyone managing a ZFS-based storage system.

CAVEATS

Operations like destroy and remove are highly destructive and irreversible; extreme caution must be exercised.
Misconfiguration of ZFS pools, especially concerning vdev layouts (mirrors, RAID-Z), can lead to data loss or poor performance.
All zpool operations typically require root privileges.
Pool version compatibility should be considered when importing pools from different ZFS implementations or older systems.

VIRTUAL DEVICES (VDEVS)

ZFS pools are built from virtual devices (VDEVs). These can be single disks, mirrors (RAID1), or RAID-Z (RAID5/6-like) groups. Special VDEVs include log devices (SLOG) for synchronous writes and cache devices (L2ARC) for read performance. Understanding VDEVs is crucial for designing resilient and performant ZFS pools with zpool create and zpool add.

POOL HEALTH AND MONITORING

The zpool status command is vital for monitoring the health of a ZFS pool. It reports on disk errors, checksum mismatches, and the status of any ongoing operations like scrubbing or resilvering. Regular monitoring and timely action based on zpool status output are key to maintaining data integrity and availability.

DATA INTEGRITY AND SELF-HEALING

A core feature of ZFS, managed through zpool, is its end-to-end data integrity. ZFS checksums all data and metadata. If corruption is detected (e.g., during a scrub or read operation), and the pool has redundancy (mirrors, RAID-Z), ZFS can automatically repair the corrupted block using a good copy from another device, a process known as self-healing.

HISTORY

ZFS (Zettabyte File System) was originally developed by Sun Microsystems in 2001 and open-sourced as part of OpenSolaris in 2005. The zpool command has been an integral part of ZFS since its inception, providing the core interface for managing storage pools. Following Oracle's acquisition of Sun, ZFS was re-implemented for Linux as ZFS on Linux (ZoL), now part of the OpenZFS project. This re-implementation brought the robust zpool functionality to the Linux environment, where it continues to be actively developed and maintained, gaining new features and performance improvements.

SEE ALSO

zfs(8), zdb(8), zed(8), parted(8), fdisk(8), mdadm(8), lvm(8)

Copied to clipboard