xref: /freebsd/sys/contrib/openzfs/man/man8/zpool.8 (revision 53b70c86)
1.\"
2.\" CDDL HEADER START
3.\"
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.
7.\"
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.
12.\"
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]
18.\"
19.\" CDDL HEADER END
20.\"
21.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
22.\" Copyright (c) 2012, 2018 by Delphix. All rights reserved.
23.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
24.\" Copyright (c) 2017 Datto Inc.
25.\" Copyright (c) 2018 George Melikov. All Rights Reserved.
26.\" Copyright 2017 Nexenta Systems, Inc.
27.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
28.\"
29.Dd June 2, 2021
30.Dt ZPOOL 8
31.Os
32.
33.Sh NAME
34.Nm zpool
35.Nd configure ZFS storage pools
36.Sh SYNOPSIS
37.Nm
38.Fl ?V
39.Nm
40.Cm version
41.Nm
42.Cm subcommand
43.Op Ar argumentss
44.
45.Sh DESCRIPTION
46The
47.Nm
48command configures ZFS storage pools.
49A storage pool is a collection of devices that provides physical storage and
50data replication for ZFS datasets.
51All datasets within a storage pool share the same space.
52See
53.Xr zfs 8
54for information on managing datasets.
55.Pp
56For an overview of creating and managing ZFS storage pools see the
57.Xr zpoolconcepts 7
58manual page.
59.
60.Sh SUBCOMMANDS
61All subcommands that modify state are logged persistently to the pool in their
62original form.
63.Pp
64The
65.Nm
66command provides subcommands to create and destroy storage pools, add capacity
67to storage pools, and provide information about the storage pools.
68The following subcommands are supported:
69.Bl -tag -width Ds
70.It Xo
71.Nm
72.Fl ?\&
73.Xc
74Displays a help message.
75.It Xo
76.Nm
77.Fl V , -version
78.Xc
79.It Xo
80.Nm
81.Cm version
82.Xc
83Displays the software version of the
84.Nm
85userland utility and the ZFS kernel module.
86.El
87.
88.Ss Creation
89.Bl -tag -width Ds
90.It Xr zpool-create 8
91Creates a new storage pool containing the virtual devices specified on the
92command line.
93.It Xr zpool-initialize 8
94Begins initializing by writing to all unallocated regions on the specified
95devices, or all eligible devices in the pool if no individual devices are
96specified.
97.El
98.
99.Ss Destruction
100.Bl -tag -width Ds
101.It Xr zpool-destroy 8
102Destroys the given pool, freeing up any devices for other use.
103.It Xr zpool-labelclear 8
104Removes ZFS label information from the specified
105.Ar device .
106.El
107.
108.Ss Virtual Devices
109.Bl -tag -width Ds
110.It Xo
111.Xr zpool-attach 8 Ns / Ns Xr zpool-detach 8
112.Xc
113Increases or decreases redundancy by
114.Cm attach Ns ing or
115.Cm detach Ns ing a device on an existing vdev (virtual device).
116.It Xo
117.Xr zpool-add 8 Ns / Ns Xr zpool-remove 8
118.Xc
119Adds the specified virtual devices to the given pool,
120or removes the specified device from the pool.
121.It Xr zpool-replace 8
122Replaces an existing device (which may be faulted) with a new one.
123.It Xr zpool-split 8
124Creates a new pool by splitting all mirrors in an existing pool (which decreases its redundancy).
125.El
126.
127.Ss Properties
128Available pool properties listed in the
129.Xr zpoolprops 7
130manual page.
131.Bl -tag -width Ds
132.It Xr zpool-list 8
133Lists the given pools along with a health status and space usage.
134.It Xo
135.Xr zpool-get 8 Ns / Ns Xr zpool-set 8
136.Xc
137Retrieves the given list of properties
138.Po
139or all properties if
140.Sy all
141is used
142.Pc
143for the specified storage pool(s).
144.El
145.
146.Ss Monitoring
147.Bl -tag -width Ds
148.It Xr zpool-status 8
149Displays the detailed health status for the given pools.
150.It Xr zpool-iostat 8
151Displays logical I/O statistics for the given pools/vdevs. Physical I/Os may
152be observed via
153.Xr iostat 1 .
154.It Xr zpool-events 8
155Lists all recent events generated by the ZFS kernel modules.
156These events are consumed by the
157.Xr zed 8
158and used to automate administrative tasks such as replacing a failed device
159with a hot spare.
160That manual page also describes the subclasses and event payloads
161that can be generated.
162.It Xr zpool-history 8
163Displays the command history of the specified pool(s) or all pools if no pool is
164specified.
165.El
166.
167.Ss Maintenance
168.Bl -tag -width Ds
169.It Xr zpool-scrub 8
170Begins a scrub or resumes a paused scrub.
171.It Xr zpool-checkpoint 8
172Checkpoints the current state of
173.Ar pool ,
174which can be later restored by
175.Nm zpool Cm import Fl -rewind-to-checkpoint .
176.It Xr zpool-trim 8
177Initiates an immediate on-demand TRIM operation for all of the free space in a pool.
178This operation informs the underlying storage devices of all blocks
179in the pool which are no longer allocated and allows thinly provisioned
180devices to reclaim the space.
181.It Xr zpool-sync 8
182This command forces all in-core dirty data to be written to the primary
183pool storage and not the ZIL.
184It will also update administrative information including quota reporting.
185Without arguments,
186.Nm zpool Cm sync
187will sync all pools on the system.
188Otherwise, it will sync only the specified pool(s).
189.It Xr zpool-upgrade 8
190Manage the on-disk format version of storage pools.
191.It Xr zpool-wait 8
192Waits until all background activity of the given types has ceased in the given
193pool.
194.El
195.
196.Ss Fault Resolution
197.Bl -tag -width Ds
198.It Xo
199.Xr zpool-offline 8 Ns / Ns Xr zpool-online 8
200.Xc
201Takes the specified physical device offline or brings it online.
202.It Xr zpool-resilver 8
203Starts a resilver.
204If an existing resilver is already running it will be restarted from the beginning.
205.It Xr zpool-reopen 8
206Reopen all the vdevs associated with the pool.
207.It Xr zpool-clear 8
208Clears device errors in a pool.
209.El
210.
211.Ss Import & Export
212.Bl -tag -width Ds
213.It Xr zpool-import 8
214Make disks containing ZFS storage pools available for use on the system.
215.It Xr zpool-export 8
216Exports the given pools from the system.
217.It Xr zpool-reguid 8
218Generates a new unique identifier for the pool.
219.El
220.
221.Sh EXIT STATUS
222The following exit values are returned:
223.Bl -tag -compact -offset 4n -width "a"
224.It Sy 0
225Successful completion.
226.It Sy 1
227An error occurred.
228.It Sy 2
229Invalid command line options were specified.
230.El
231.
232.Sh EXAMPLES
233.Bl -tag -width "Exam"
234.It Sy Example 1 : No Creating a RAID-Z Storage Pool
235The following command creates a pool with a single raidz root vdev that
236consists of six disks:
237.Dl # Nm zpool Cm create Ar tank Sy raidz Ar sda sdb sdc sdd sde sdf
238.
239.It Sy Example 2 : No Creating a Mirrored Storage Pool
240The following command creates a pool with two mirrors, where each mirror
241contains two disks:
242.Dl # Nm zpool Cm create Ar tank Sy mirror Ar sda sdb Sy mirror Ar sdc sdd
243.
244.It Sy Example 3 : No Creating a ZFS Storage Pool by Using Partitions
245The following command creates an unmirrored pool using two disk partitions:
246.Dl # Nm zpool Cm create Ar tank sda1 sdb2
247.
248.It Sy Example 4 : No Creating a ZFS Storage Pool by Using Files
249The following command creates an unmirrored pool using files.
250While not recommended, a pool based on files can be useful for experimental
251purposes.
252.Dl # Nm zpool Cm create Ar tank /path/to/file/a /path/to/file/b
253.
254.It Sy Example 5 : No Adding a Mirror to a ZFS Storage Pool
255The following command adds two mirrored disks to the pool
256.Ar tank ,
257assuming the pool is already made up of two-way mirrors.
258The additional space is immediately available to any datasets within the pool.
259.Dl # Nm zpool Cm add Ar tank Sy mirror Ar sda sdb
260.
261.It Sy Example 6 : No Listing Available ZFS Storage Pools
262The following command lists all available pools on the system.
263In this case, the pool
264.Ar zion
265is faulted due to a missing device.
266The results from this command are similar to the following:
267.Bd -literal -compact -offset Ds
268.No # Nm zpool Cm list
269NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
270rpool  19.9G  8.43G  11.4G         -    33%    42%  1.00x  ONLINE  -
271tank   61.5G  20.0G  41.5G         -    48%    32%  1.00x  ONLINE  -
272zion       -      -      -         -      -      -      -  FAULTED -
273.Ed
274.
275.It Sy Example 7 : No Destroying a ZFS Storage Pool
276The following command destroys the pool
277.Ar tank
278and any datasets contained within:
279.Dl # Nm zpool Cm destroy Fl f Ar tank
280.
281.It Sy Example 8 : No Exporting a ZFS Storage Pool
282The following command exports the devices in pool
283.Ar tank
284so that they can be relocated or later imported:
285.Dl # Nm zpool Cm export Ar tank
286.
287.It Sy Example 9 : No Importing a ZFS Storage Pool
288The following command displays available pools, and then imports the pool
289.Ar tank
290for use on the system.
291The results from this command are similar to the following:
292.Bd -literal -compact -offset Ds
293.No # Nm zpool Cm import
294  pool: tank
295    id: 15451357997522795478
296 state: ONLINE
297action: The pool can be imported using its name or numeric identifier.
298config:
299
300        tank        ONLINE
301          mirror    ONLINE
302            sda     ONLINE
303            sdb     ONLINE
304
305.No # Nm zpool Cm import Ar tank
306.Ed
307.
308.It Sy Example 10 : No Upgrading All ZFS Storage Pools to the Current Version
309The following command upgrades all ZFS Storage pools to the current version of
310the software:
311.Bd -literal -compact -offset Ds
312.No # Nm zpool Cm upgrade Fl a
313This system is currently running ZFS version 2.
314.Ed
315.
316.It Sy Example 11 : No Managing Hot Spares
317The following command creates a new pool with an available hot spare:
318.Dl # Nm zpool Cm create Ar tank Sy mirror Ar sda sdb Sy spare Ar sdc
319.Pp
320If one of the disks were to fail, the pool would be reduced to the degraded
321state.
322The failed device can be replaced using the following command:
323.Dl # Nm zpool Cm replace Ar tank sda sdd
324.Pp
325Once the data has been resilvered, the spare is automatically removed and is
326made available for use should another device fail.
327The hot spare can be permanently removed from the pool using the following
328command:
329.Dl # Nm zpool Cm remove Ar tank sdc
330.
331.It Sy Example 12 : No Creating a ZFS Pool with Mirrored Separate Intent Logs
332The following command creates a ZFS storage pool consisting of two, two-way
333mirrors and mirrored log devices:
334.Dl # Nm zpool Cm create Ar pool Sy mirror Ar sda sdb Sy mirror Ar sdc sdd Sy log mirror Ar sde sdf
335.
336.It Sy Example 13 : No Adding Cache Devices to a ZFS Pool
337The following command adds two disks for use as cache devices to a ZFS storage
338pool:
339.Dl # Nm zpool Cm add Ar pool Sy cache Ar sdc sdd
340.Pp
341Once added, the cache devices gradually fill with content from main memory.
342Depending on the size of your cache devices, it could take over an hour for
343them to fill.
344Capacity and reads can be monitored using the
345.Cm iostat
346subcommand as follows:
347.Dl # Nm zpool Cm iostat Fl v Ar pool 5
348.
349.It Sy Example 14 : No Removing a Mirrored top-level (Log or Data) Device
350The following commands remove the mirrored log device
351.Sy mirror-2
352and mirrored top-level data device
353.Sy mirror-1 .
354.Pp
355Given this configuration:
356.Bd -literal -compact -offset Ds
357  pool: tank
358 state: ONLINE
359 scrub: none requested
360config:
361
362         NAME        STATE     READ WRITE CKSUM
363         tank        ONLINE       0     0     0
364           mirror-0  ONLINE       0     0     0
365             sda     ONLINE       0     0     0
366             sdb     ONLINE       0     0     0
367           mirror-1  ONLINE       0     0     0
368             sdc     ONLINE       0     0     0
369             sdd     ONLINE       0     0     0
370         logs
371           mirror-2  ONLINE       0     0     0
372             sde     ONLINE       0     0     0
373             sdf     ONLINE       0     0     0
374.Ed
375.Pp
376The command to remove the mirrored log
377.Ar mirror-2 No is:
378.Dl # Nm zpool Cm remove Ar tank mirror-2
379.Pp
380The command to remove the mirrored data
381.Ar mirror-1 No is:
382.Dl # Nm zpool Cm remove Ar tank mirror-1
383.
384.It Sy Example 15 : No Displaying expanded space on a device
385The following command displays the detailed information for the pool
386.Ar data .
387This pool is comprised of a single raidz vdev where one of its devices
388increased its capacity by 10GB.
389In this example, the pool will not be able to utilize this extra capacity until
390all the devices under the raidz vdev have been expanded.
391.Bd -literal -compact -offset Ds
392.No # Nm zpool Cm list Fl v Ar data
393NAME         SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
394data        23.9G  14.6G  9.30G         -    48%    61%  1.00x  ONLINE  -
395  raidz1    23.9G  14.6G  9.30G         -    48%
396    sda         -      -      -         -      -
397    sdb         -      -      -       10G      -
398    sdc         -      -      -         -      -
399.Ed
400.
401.It Sy Example 16 : No Adding output columns
402Additional columns can be added to the
403.Nm zpool Cm status No and Nm zpool Cm iostat No output with Fl c .
404.Bd -literal -compact -offset Ds
405.No # Nm zpool Cm status Fl c Ar vendor , Ns Ar model , Ns Ar size
406   NAME     STATE  READ WRITE CKSUM vendor  model        size
407   tank     ONLINE 0    0     0
408   mirror-0 ONLINE 0    0     0
409   U1       ONLINE 0    0     0     SEAGATE ST8000NM0075 7.3T
410   U10      ONLINE 0    0     0     SEAGATE ST8000NM0075 7.3T
411   U11      ONLINE 0    0     0     SEAGATE ST8000NM0075 7.3T
412   U12      ONLINE 0    0     0     SEAGATE ST8000NM0075 7.3T
413   U13      ONLINE 0    0     0     SEAGATE ST8000NM0075 7.3T
414   U14      ONLINE 0    0     0     SEAGATE ST8000NM0075 7.3T
415
416.No # Nm zpool Cm iostat Fl vc Ar size
417              capacity     operations     bandwidth
418pool        alloc   free   read  write   read  write  size
419----------  -----  -----  -----  -----  -----  -----  ----
420rpool       14.6G  54.9G      4     55   250K  2.69M
421  sda1      14.6G  54.9G      4     55   250K  2.69M   70G
422----------  -----  -----  -----  -----  -----  -----  ----
423.Ed
424.El
425.
426.Sh ENVIRONMENT VARIABLES
427.Bl -tag -compact -width "ZPOOL_IMPORT_UDEV_TIMEOUT_MS"
428.It Sy ZFS_ABORT
429Cause
430.Nm
431to dump core on exit for the purposes of running
432.Sy ::findleaks .
433.It Sy ZFS_COLOR
434Use ANSI color in
435.Nm zpool status
436output.
437.It Sy ZPOOL_IMPORT_PATH
438The search path for devices or files to use with the pool.
439This is a colon-separated list of directories in which
440.Nm
441looks for device nodes and files.
442Similar to the
443.Fl d
444option in
445.Nm zpool import .
446.It Sy ZPOOL_IMPORT_UDEV_TIMEOUT_MS
447The maximum time in milliseconds that
448.Nm zpool import
449will wait for an expected device to be available.
450.It Sy ZPOOL_STATUS_NON_NATIVE_ASHIFT_IGNORE
451If set, suppress warning about non-native vdev ashift in
452.Nm zpool status .
453The value is not used, only the presence or absence of the variable matters.
454.It Sy ZPOOL_VDEV_NAME_GUID
455Cause
456.Nm
457subcommands to output vdev guids by default.
458This behavior is identical to the
459.Nm zpool Cm status Fl g
460command line option.
461.It Sy ZPOOL_VDEV_NAME_FOLLOW_LINKS
462Cause
463.Nm
464subcommands to follow links for vdev names by default.
465This behavior is identical to the
466.Nm zpool Cm status Fl L
467command line option.
468.It Sy ZPOOL_VDEV_NAME_PATH
469Cause
470.Nm
471subcommands to output full vdev path names by default.
472This behavior is identical to the
473.Nm zpool Cm status Fl P
474command line option.
475.It Sy ZFS_VDEV_DEVID_OPT_OUT
476Older OpenZFS implementations had issues when attempting to display pool
477config VDEV names if a
478.Sy devid
479NVP value is present in the pool's config.
480.Pp
481For example, a pool that originated on illumos platform would have a
482.Sy devid
483value in the config and
484.Nm zpool status
485would fail when listing the config.
486This would also be true for future Linux-based pools.
487.Pp
488A pool can be stripped of any
489.Sy devid
490values on import or prevented from adding
491them on
492.Nm zpool Cm create
493or
494.Nm zpool Cm add
495by setting
496.Sy ZFS_VDEV_DEVID_OPT_OUT .
497.Pp
498.It Sy ZPOOL_SCRIPTS_AS_ROOT
499Allow a privileged user to run
500.Nm zpool status/iostat Fl c .
501Normally, only unprivileged users are allowed to run
502.Fl c .
503.It Sy ZPOOL_SCRIPTS_PATH
504The search path for scripts when running
505.Nm zpool status/iostat Fl c .
506This is a colon-separated list of directories and overrides the default
507.Pa ~/.zpool.d
508and
509.Pa /etc/zfs/zpool.d
510search paths.
511.It Sy ZPOOL_SCRIPTS_ENABLED
512Allow a user to run
513.Nm zpool status/iostat Fl c .
514If
515.Sy ZPOOL_SCRIPTS_ENABLED
516is not set, it is assumed that the user is allowed to run
517.Nm zpool Cm status Ns / Ns Cm iostat Fl c .
518.El
519.
520.Sh INTERFACE STABILITY
521.Sy Evolving
522.
523.Sh SEE ALSO
524.Xr zfs 4 ,
525.Xr zpool-features 7 ,
526.Xr zpoolconcepts 7 ,
527.Xr zpoolprops 7 ,
528.Xr zed 8 ,
529.Xr zfs 8 ,
530.Xr zpool-add 8 ,
531.Xr zpool-attach 8 ,
532.Xr zpool-checkpoint 8 ,
533.Xr zpool-clear 8 ,
534.Xr zpool-create 8 ,
535.Xr zpool-destroy 8 ,
536.Xr zpool-detach 8 ,
537.Xr zpool-events 8 ,
538.Xr zpool-export 8 ,
539.Xr zpool-get 8 ,
540.Xr zpool-history 8 ,
541.Xr zpool-import 8 ,
542.Xr zpool-initialize 8 ,
543.Xr zpool-iostat 8 ,
544.Xr zpool-labelclear 8 ,
545.Xr zpool-list 8 ,
546.Xr zpool-offline 8 ,
547.Xr zpool-online 8 ,
548.Xr zpool-reguid 8 ,
549.Xr zpool-remove 8 ,
550.Xr zpool-reopen 8 ,
551.Xr zpool-replace 8 ,
552.Xr zpool-resilver 8 ,
553.Xr zpool-scrub 8 ,
554.Xr zpool-set 8 ,
555.Xr zpool-split 8 ,
556.Xr zpool-status 8 ,
557.Xr zpool-sync 8 ,
558.Xr zpool-trim 8 ,
559.Xr zpool-upgrade 8 ,
560.Xr zpool-wait 8
561