30.2. Creating and Managing Pools
Pool creation is deliberately destructive to existing signatures on the member devices. Identify the devices twice, confirm that they contain no wanted data, and prefer persistent identifiers over kernel-assigned names. The examples use small virtio disks so the layout is easy to see; the commands are the same for larger disks.
30.2.1. Identifying Disposable Data Devices and Creating a Pool
On zfs1, as john, list the block devices and their mountpoints:
$ lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
NAME SIZE TYPE MOUNTPOINT
vda 100G disk
└─vda1 100G part /
vdb 1G disk
vdc 1G disk
vdd 1G disk
vde 1G disk
vdf 1G disk
vdg 1G disk
vda holds the root filesystem. vdb through vdg are unpartitioned,
unmounted disks reserved for this exercise. On a physical system the same
inspection would show model, serial, and by-id links; these virtio disks do not
expose serial-based by-id names, so the examples use the stable-for-this-boot
virtio names. A production command should use a path such as
/dev/disk/by-id/ata-WDC_WD40EFRX-68N32N0_WD-WCC7K0XXXXXX so that a reboot or
controller reordering cannot swap the devices.
Check for existing filesystem, RAID, or ZFS signatures on the intended members:
$ sudo lsblk -f /dev/vdb /dev/vdc
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
vdb
vdc
Empty FSTYPE and UUID fields mean no recognized signature. A nonempty
zfs_member label means the disk belongs to an existing pool; do not overwrite
it without determining whether that pool is still needed. wipefs -n can show
signatures without changing them, and zpool labelclear removes ZFS labels
from a device that is no longer part of a pool.
Enter the root shell for the storage commands:
$ sudo -i
The shell prompt changes to #; no command output is printed. The examples
below that use # assume this shell. Leave it with exit when returning to
john's commands.
Create a two-disk mirror with 4 KiB alignment:
# zpool create -o ashift=12 tank mirror /dev/vdb /dev/vdc
The command normally produces no output. zpool create writes labels, creates
the pool, and mounts its root dataset at /tank by default. The options used
here and the ones most often needed for a first pool are:
| Option | Description |
|---|---|
-o ashift=12 |
Sets the minimum allocation shift to 4 KiB, appropriate for 512e and 4Kn devices |
-o autoexpand=on |
Grows the pool automatically when all devices in a vdev report a larger size |
-o autoreplace=on |
Automatically formats and replaces a failed device when a new device appears in the same physical location, such as the same by-id path after a slot swap |
-m mountpoint |
Sets the root dataset mountpoint; -m none leaves it unmounted |
-R root |
Sets an alternate root directory for mountpoints during import or creation |
-n |
Performs a dry run and prints the configuration without creating it |
-f |
Forces creation despite an existing signature or a potentially active pool; use with extreme care |
Verify that ZFS claimed the devices and created its own partition labels:
# lsblk -f /dev/vdb /dev/vdc
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
vdb
├─vdb1 zfs_member 5000 tank 13640682405686340337
└─vdb9
vdc
├─vdc1 zfs_member 5000 tank 13640682405686340337
└─vdc9
The zfs_member partitions are ZFS labels, not ordinary filesystems to mount.
The vdb9 and vdc9 partitions are small reserved areas used by the ZFS
label scheme. Do not format or mount these partitions, and do not use fdisk
or parted to edit a disk that belongs to an active pool. lsblk showing the
same pool UUID on both members is expected for a mirror.
The pool status shows the vdev tree and the health of each member:
# zpool status tank
pool: tank
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
vdb ONLINE 0 0 0
vdc ONLINE 0 0 0
errors: No known data errors
ONLINE means the device is present and participating. READ, WRITE, and
CKSUM count errors since the last zpool clear or import. A nonzero checksum
count on a redundant vdev can be repaired by a scrub; a nonzero count on a
nonredundant vdev means data loss unless another copy exists.
30.2.2. Inspecting Pool Topology, Capacity, and Health
zpool list gives a compact summary; zpool list -v expands the vdev tree:
# zpool list -v tank
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
tank 960M 480K 960M - - 2% 0% 1.00x ONLINE -
mirror-0 960M 480K 960M - - 2% 0.04% - ONLINE
vdb 1014M - - - - - - - ONLINE
vdc 1014M - - - - - - - ONLINE
A custom field list is easier to read when many pools exist:
# zpool list -o name,size,alloc,free,cap,health,frag
NAME SIZE ALLOC FREE CAP HEALTH FRAG
tank 960M 480K 960M 0% ONLINE 2%
SIZE is the raw usable size of the vdev topology, not the sum of the member
disks. A two-disk mirror of 1 GiB devices reports about 960 MiB, because a
small amount is consumed by labels and alignment and one copy is stored. CAP
is allocated space as a percentage of SIZE; FRAG estimates free-space
fragmentation. EXPANDSZ appears when a device has grown but the pool has not
yet used the new space.
Unprivileged users can read the summary on many systems:
$ zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
tank 960M 372K 960M - - 2% 0% 1.00x ONLINE -
The small difference in ALLOC from the root-shell command is normal: the
first command ran while the pool was still settling, and ZFS updates accounting
asynchronously. The view is a snapshot, not a transactionally frozen number.
The filesystem-visible capacity differs from the pool summary:
$ df -h /tank
Filesystem Size Used Avail Use% Mounted on
tank 832M 128K 832M 1% /tank
The dataset reports 832 MiB available on a pool whose raw SIZE is 960 MiB.
The difference comes from ZFS metadata, the pool's slop space, and allocation
policy. df reports the dataset's view; zpool list reports raw vdev capacity;
zfs list reports dataset accounting including snapshots and children. None of
the three is wrong, but they answer different questions.
Figure 30.3. Conceptual capacity accounting from member disks to a mounted dataset. Quotas and reservations act on the dataset layer; pool slop and metadata are outside any single dataset. The figures are from the practice mirror and are illustrative, not a sizing rule.
A health-only query is useful in monitoring:
# zpool status -x
all pools are healthy
-x prints only pools that are not healthy. A monitoring script can treat
nonzero output as an alert, but it should also inspect zpool status -v when a
pool is degraded, because -x deliberately keeps the output short.
The status and listing options used in this chapter are:
| Option | Description |
|---|---|
zpool status -x |
Prints only pools that are not healthy |
zpool status -v |
Includes the error list and affected file names |
zpool status -L |
Displays real device paths for vdevs, resolving symbolic links |
zpool list -v |
Expands top-level vdevs and member devices |
zpool list -o field,... |
Selects and orders columns |
zpool list -H |
Suppresses the header, which is useful in scripts |
30.2.3. Adding Capacity and Checking Version-Specific Expansion Capabilities
There are three common ways to add capacity to an existing pool: add a new
top-level vdev, attach a disk to a mirror, or expand a RAIDZ vdev by attaching
another disk. Adding a top-level vdev changes the pool's failure domain;
removing it later requires zpool remove and is only possible under
constraints such as the absence of a top-level RAIDZ vdev. Attaching to a mirror adds redundancy and
capacity to that mirror; RAIDZ expansion adds capacity to an existing RAIDZ
vdev.
Create a second pool to demonstrate RAIDZ expansion:
# zpool create -o ashift=12 raidpool raidz1 /dev/vdd /dev/vde
The two-disk RAIDZ1 here fits the small practice disks. A production RAIDZ1 normally uses at least three disks; with two disks it provides mirror-like capacity and only one parity block across a very small vdev. The command is silent. Its status and capacity are:
# zpool status raidpool
pool: raidpool
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
raidpool ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
vdd ONLINE 0 0 0
vde ONLINE 0 0 0
errors: No known data errors
# zpool list -v raidpool
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
raidpool 1.88G 888K 1.87G - - 1% 0% 1.00x ONLINE -
raidz1-0 1.88G 888K 1.87G - - 1% 0.04% - ONLINE
vdd 1014M - - - - - - - ONLINE
vde 1014M - - - - - - - ONLINE
The initial SIZE is about 1.88 GiB from two 1 GiB devices. RAIDZ1 keeps one
device's worth of parity, so the usable capacity is roughly one device, not two
times one device. The exact number is lower because of labels, alignment, and
metadata.
Check whether automatic growth is enabled:
# zpool get autoexpand tank
NAME PROPERTY VALUE SOURCE
tank autoexpand off default
autoexpand applies when the underlying device reports a larger size, as with
a grown LUN. It does not control RAIDZ expansion by attaching a disk. Leave it
off unless you want the pool to consume a grown LUN automatically; an
unexpected expansion can change capacity accounting and monitoring thresholds.
Attach a third disk to the RAIDZ vdev:
# zpool attach raidpool raidz1-0 /dev/vdg
The command is silent and returns while the expansion runs in the background. The relevant options are:
| Option | Description |
|---|---|
-o ashift=12 |
Sets alignment for the new device; the only property supported when attaching to a RAIDZ vdev |
-w |
Waits for the resilver or expansion to finish before returning |
-f |
Forces use of the new device even if it appears to be in use |
zpool attach on a mirror adds a mirror leg. On a RAIDZ vdev it starts a
RAIDZ expansion: existing blocks are copied into a new layout, and the vdev
gains one device's worth of capacity while preserving its fault tolerance. The
expansion does not increase the number of failures the vdev can tolerate; a
RAIDZ1 vdev remains RAIDZ1.
While the expansion runs, status shows progress:
# zpool status raidpool
pool: raidpool
state: ONLINE
expand: expansion of raidz1-0 in progress since Tue Nov 24 14:53:21 2026
868K / 864K copied at 289K/s, 100.46% done, (copy is slow, no estimated time)
config:
NAME STATE READ WRITE CKSUM
raidpool ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
vdd ONLINE 0 0 0
vde ONLINE 0 0 0
vdg ONLINE 0 0 0
errors: No known data errors
A progress figure above 100% can occur on a very small pool because of
accounting granularity; the expansion is not complete until the expand: line changes to expanded
and the pool-wide scrub finishes. On a large vdev, expect a long copy and a
scrub afterwards. Do not remove a member during the expansion.
The completed state is:
# zpool status raidpool
pool: raidpool
state: ONLINE
scan: scrub repaired 0B in 00:00:00 with 0 errors on Tue Nov 24 14:53:25 2026
expand: expanded raidz1-0 copied 1.14M in 00:00:04, on Tue Nov 24 14:53:25 2026
config:
NAME STATE READ WRITE CKSUM
raidpool ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
vdd ONLINE 0 0 0
vde ONLINE 0 0 0
vdg ONLINE 0 0 0
errors: No known data errors
The pool now reports three devices' worth of raw size:
# zpool list -v raidpool
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
raidpool 2.88G 1.31M 2.87G - - 3% 0% 1.00x ONLINE -
raidz1-0 2.88G 1.31M 2.87G - - 3% 0.04% - ONLINE
vdd 1014M - - - - - - - ONLINE
vde 1014M - - - - - - - ONLINE
vdg 1014M - - - - - - - ONLINE
zpool get expandsize reports no pending device growth:
# zpool get expandsize raidpool
NAME PROPERTY VALUE SOURCE
raidpool expandsize - -
RAIDZ expansion has two important caveats. First, old blocks keep the parity
ratio they were written with; new blocks use the new ratio. The pool may
therefore report slightly less usable space than an arithmetic calculation
suggests, and rewriting old data improves the ratio only as blocks are
rewritten. Second, expansion is a copy-and-scrub operation, not an instant
metadata change. Plan it for a maintenance window, monitor zpool status, and
make sure the pool has a backup before starting. zpool add with a new vdev is faster but changes the pool's failure domain;
removing a top-level vdev later is constrained and not always possible.
zpool add and zpool attach are not interchangeable:
| Command | Effect | Reversible? |
|---|---|---|
zpool add tank mirror /dev/vdx /dev/vdy |
Adds a new top-level mirror vdev; data is striped across old and new vdevs | Conditionally: zpool remove works only with no top-level RAIDZ and matching sector sizes |
zpool attach tank /dev/vdb /dev/vdx |
Adds a leg to the mirror containing /dev/vdb |
Yes, zpool detach removes the added leg |
zpool add tank raidz2 /dev/vdx /dev/vdy ... |
Adds a new top-level RAIDZ vdev | No; a top-level RAIDZ vdev cannot be removed from the pool |
zpool attach tank raidz1-0 /dev/vdx |
Expands an existing RAIDZ vdev | Expansion is permanent in the current OpenZFS implementation |
30.2.4. Exporting, Importing, and Moving Pools Between Hosts
A pool must be exported before its disks are moved to another host. Export unmounts datasets, flushes pending writes, and marks the pool as cleanly exported. Import scans the devices, reads the labels, and brings the pool back. A pool that is already imported cannot be imported again under the same name:
# zpool import tank
cannot import 'tank': a pool with that name already exists
use the form 'zpool import <pool | id> <newpool>' to give it a new name
This is a safety check, not a corruption. If the pool is genuinely still in use on this host, stop using it and do not import it elsewhere. If the pool is imported on another host, importing it here would give two writers to the same blocks and corrupt the pool.
Host identity matters for pools that may be shared. The host ID and its file are:
# hostid
12345678
# ls -l /etc/hostid
-rw-r--r-- 1 root root 4 Nov 24 14:48 /etc/hostid
The four-byte /etc/hostid value is generated by zgenhostid on systems that
do not have a firmware-provided host ID. It is part of the multihost safety
mechanism described in Section 30.6.3. Do not copy one host's /etc/hostid to
another host that may share storage.
Export the pool cleanly:
# zpool export tank
The command is silent. The pool disappears from the local list:
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
raidpool 2.88G 1.05M 2.87G - - 3% 0% 1.00x ONLINE -
A scan shows the exported pool and its numeric ID:
# zpool import
pool: tank
id: 13640682405686340337
state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
tank ONLINE
mirror-0 ONLINE
vdb ONLINE
vdc ONLINE
Import it by name:
# zpool import tank
The command is silent. Verify that the pool is back and healthy:
# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
raidpool 2.88G 1.05M 2.87G - - 3% 0% 1.00x ONLINE -
tank 960M 492K 960M - - 4% 0% 1.00x ONLINE -
# zpool status -x
all pools are healthy
The import options that matter when moving storage are:
| Option | Description |
|---|---|
-a |
Imports all pools found on the system |
-d directory |
Searches a directory such as /dev/disk/by-id for devices |
-f |
Forces import of a pool that appears active or has a hostid mismatch; use only after verifying the other host is not using it |
-N |
Imports without mounting datasets; useful for recovery and inspection |
-l |
Loads encryption keys for encrypted datasets during import |
-c cachefile |
Imports pools listed in a cache file instead of scanning all devices |
-o property=value |
Sets a pool property, such as altroot, during import |
-R root |
Sets an alternate root for all dataset mountpoints |
On zfs2, an import scan finds nothing; no pool has been created there yet,
and the backup pool used for replication is created in Section 30.4.4:
# zpool import
no pools available to import
When moving physical disks, shut down or export on the old host, move the
disks, confirm the new host sees the expected by-id paths, and import by ID
rather than by a kernel name that may have changed. If the old host is
unavailable and the pool was not exported, zpool import may warn that the
pool was last accessed by another system. Verify that the old host is powered
off or disconnected before using -f.