xref: /freebsd/sys/contrib/openzfs/man/man8/zpool-import.8 (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1.\" SPDX-License-Identifier: CDDL-1.0
2.\"
3.\" CDDL HEADER START
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or https://opensource.org/licenses/CDDL-1.0.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.\" CDDL HEADER END
21.\"
22.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
23.\" Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
25.\" Copyright (c) 2017 Datto Inc.
26.\" Copyright (c) 2018 George Melikov. All Rights Reserved.
27.\" Copyright 2017 Nexenta Systems, Inc.
28.\" Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
29.\"
30.Dd March 16, 2022
31.Dt ZPOOL-IMPORT 8
32.Os
33.
34.Sh NAME
35.Nm zpool-import
36.Nd import ZFS storage pools or list available pools
37.Sh SYNOPSIS
38.Nm zpool
39.Cm import
40.Op Fl D
41.Oo Fl d Ar dir Ns | Ns Ar device Oc Ns …
42.Nm zpool
43.Cm import
44.Fl a
45.Op Fl DflmN
46.Op Fl F Op Fl nTX
47.Op Fl -rewind-to-checkpoint
48.Op Fl c Ar cachefile Ns | Ns Fl d Ar dir Ns | Ns Ar device
49.Op Fl o Ar mntopts
50.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
51.Op Fl R Ar root
52.Nm zpool
53.Cm import
54.Op Fl Dflmt
55.Op Fl F Op Fl nTX
56.Op Fl -rewind-to-checkpoint
57.Op Fl c Ar cachefile Ns | Ns Fl d Ar dir Ns | Ns Ar device
58.Op Fl o Ar mntopts
59.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
60.Op Fl R Ar root
61.Op Fl s
62.Ar pool Ns | Ns Ar id
63.Op Ar newpool
64.
65.Sh DESCRIPTION
66.Bl -tag -width Ds
67.It Xo
68.Nm zpool
69.Cm import
70.Op Fl D
71.Oo Fl d Ar dir Ns | Ns Ar device Oc Ns …
72.Xc
73Lists pools available to import.
74If the
75.Fl d
76or
77.Fl c
78options are not specified, this command searches for devices using libblkid
79on Linux and geom on
80.Fx .
81The
82.Fl d
83option can be specified multiple times, and all directories are searched.
84If the device appears to be part of an exported pool, this command displays a
85summary of the pool with the name of the pool, a numeric identifier, as well as
86the vdev layout and current health of the device for each device or file.
87Destroyed pools, pools that were previously destroyed with the
88.Nm zpool Cm destroy
89command, are not listed unless the
90.Fl D
91option is specified.
92.Pp
93The numeric identifier is unique, and can be used instead of the pool name when
94multiple exported pools of the same name are available.
95.Bl -tag -width Ds
96.It Fl c Ar cachefile
97Reads configuration from the given
98.Ar cachefile
99that was created with the
100.Sy cachefile
101pool property.
102This
103.Ar cachefile
104is used instead of searching for devices.
105.It Fl d Ar dir Ns | Ns Ar device
106Uses
107.Ar device
108or searches for devices or files in
109.Ar dir .
110The
111.Fl d
112option can be specified multiple times.
113.It Fl D
114Lists destroyed pools only.
115.El
116.It Xo
117.Nm zpool
118.Cm import
119.Fl a
120.Op Fl DflmN
121.Op Fl F Op Fl nTX
122.Op Fl c Ar cachefile Ns | Ns Fl d Ar dir Ns | Ns Ar device
123.Op Fl o Ar mntopts
124.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
125.Op Fl R Ar root
126.Op Fl s
127.Xc
128Imports all pools found in the search directories.
129Identical to the previous command, except that all pools with a sufficient
130number of devices available are imported.
131Destroyed pools, pools that were previously destroyed with the
132.Nm zpool Cm destroy
133command, will not be imported unless the
134.Fl D
135option is specified.
136.Bl -tag -width Ds
137.It Fl a
138Searches for and imports all pools found.
139.It Fl c Ar cachefile
140Reads configuration from the given
141.Ar cachefile
142that was created with the
143.Sy cachefile
144pool property.
145This
146.Ar cachefile
147is used instead of searching for devices.
148.It Fl d Ar dir Ns | Ns Ar device
149Uses
150.Ar device
151or searches for devices or files in
152.Ar dir .
153The
154.Fl d
155option can be specified multiple times.
156This option is incompatible with the
157.Fl c
158option.
159.It Fl D
160Imports destroyed pools only.
161The
162.Fl f
163option is also required.
164.It Fl f
165Forces import, even if the pool appears to be potentially active.
166.It Fl F
167Recovery mode for a non-importable pool.
168Attempt to return the pool to an importable state by discarding the last few
169transactions.
170Not all damaged pools can be recovered by using this option.
171If successful, the data from the discarded transactions is irretrievably lost.
172This option is ignored if the pool is importable or already imported.
173.It Fl l
174Indicates that this command will request encryption keys for all encrypted
175datasets it attempts to mount as it is bringing the pool online.
176Note that if any datasets have a
177.Sy keylocation
178of
179.Sy prompt
180this command will block waiting for the keys to be entered.
181Without this flag
182encrypted datasets will be left unavailable until the keys are loaded.
183.It Fl m
184Allows a pool to import when there is a missing log device.
185Recent transactions can be lost because the log device will be discarded.
186.It Fl n
187Used with the
188.Fl F
189recovery option.
190Determines whether a non-importable pool can be made importable again, but does
191not actually perform the pool recovery.
192For more details about pool recovery mode, see the
193.Fl F
194option, above.
195.It Fl N
196Import the pool without mounting any file systems.
197.It Fl o Ar mntopts
198Comma-separated list of mount options to use when mounting datasets within the
199pool.
200See
201.Xr zfs 8
202for a description of dataset properties and mount options.
203.It Fl o Ar property Ns = Ns Ar value
204Sets the specified property on the imported pool.
205See the
206.Xr zpoolprops 7
207manual page for more information on the available pool properties.
208.It Fl R Ar root
209Sets the
210.Sy cachefile
211property to
212.Sy none
213and the
214.Sy altroot
215property to
216.Ar root .
217.It Fl -rewind-to-checkpoint
218Rewinds pool to the checkpointed state.
219Once the pool is imported with this flag there is no way to undo the rewind.
220All changes and data that were written after the checkpoint are lost!
221The only exception is when the
222.Sy readonly
223mounting option is enabled.
224In this case, the checkpointed state of the pool is opened and an
225administrator can see how the pool would look like if they were
226to fully rewind.
227.It Fl s
228Scan using the default search path, the libblkid cache will not be
229consulted.
230A custom search path may be specified by setting the
231.Sy ZPOOL_IMPORT_PATH
232environment variable.
233.It Fl X
234Used with the
235.Fl F
236recovery option.
237Determines whether extreme measures to find a valid txg should take place.
238This allows the pool to
239be rolled back to a txg which is no longer guaranteed to be consistent.
240Pools imported at an inconsistent txg may contain uncorrectable checksum errors.
241For more details about pool recovery mode, see the
242.Fl F
243option, above.
244WARNING: This option can be extremely hazardous to the
245health of your pool and should only be used as a last resort.
246.It Fl T
247Specify the txg to use for rollback.
248Implies
249.Fl FX .
250For more details
251about pool recovery mode, see the
252.Fl X
253option, above.
254WARNING: This option can be extremely hazardous to the
255health of your pool and should only be used as a last resort.
256.El
257.It Xo
258.Nm zpool
259.Cm import
260.Op Fl Dflmt
261.Op Fl F Op Fl nTX
262.Op Fl c Ar cachefile Ns | Ns Fl d Ar dir Ns | Ns Ar device
263.Op Fl o Ar mntopts
264.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
265.Op Fl R Ar root
266.Op Fl s
267.Ar pool Ns | Ns Ar id
268.Op Ar newpool
269.Xc
270Imports a specific pool.
271A pool can be identified by its name or the numeric identifier.
272If
273.Ar newpool
274is specified, the pool is imported using the name
275.Ar newpool .
276Otherwise, it is imported with the same name as its exported name.
277.Pp
278If a device is removed from a system without running
279.Nm zpool Cm export
280first, the device appears as potentially active.
281It cannot be determined if this was a failed export, or whether the device is
282really in use from another host.
283To import a pool in this state, the
284.Fl f
285option is required.
286.Bl -tag -width Ds
287.It Fl c Ar cachefile
288Reads configuration from the given
289.Ar cachefile
290that was created with the
291.Sy cachefile
292pool property.
293This
294.Ar cachefile
295is used instead of searching for devices.
296.It Fl d Ar dir Ns | Ns Ar device
297Uses
298.Ar device
299or searches for devices or files in
300.Ar dir .
301The
302.Fl d
303option can be specified multiple times.
304This option is incompatible with the
305.Fl c
306option.
307.It Fl D
308Imports destroyed pool.
309The
310.Fl f
311option is also required.
312.It Fl f
313Forces import, even if the pool appears to be potentially active.
314.It Fl F
315Recovery mode for a non-importable pool.
316Attempt to return the pool to an importable state by discarding the last few
317transactions.
318Not all damaged pools can be recovered by using this option.
319If successful, the data from the discarded transactions is irretrievably lost.
320This option is ignored if the pool is importable or already imported.
321.It Fl l
322Indicates that this command will request encryption keys for all encrypted
323datasets it attempts to mount as it is bringing the pool online.
324Note that if any datasets have a
325.Sy keylocation
326of
327.Sy prompt
328this command will block waiting for the keys to be entered.
329Without this flag
330encrypted datasets will be left unavailable until the keys are loaded.
331.It Fl m
332Allows a pool to import when there is a missing log device.
333Recent transactions can be lost because the log device will be discarded.
334.It Fl n
335Used with the
336.Fl F
337recovery option.
338Determines whether a non-importable pool can be made importable again, but does
339not actually perform the pool recovery.
340For more details about pool recovery mode, see the
341.Fl F
342option, above.
343.It Fl o Ar mntopts
344Comma-separated list of mount options to use when mounting datasets within the
345pool.
346See
347.Xr zfs 8
348for a description of dataset properties and mount options.
349.It Fl o Ar property Ns = Ns Ar value
350Sets the specified property on the imported pool.
351See the
352.Xr zpoolprops 7
353manual page for more information on the available pool properties.
354.It Fl R Ar root
355Sets the
356.Sy cachefile
357property to
358.Sy none
359and the
360.Sy altroot
361property to
362.Ar root .
363.It Fl s
364Scan using the default search path, the libblkid cache will not be
365consulted.
366A custom search path may be specified by setting the
367.Sy ZPOOL_IMPORT_PATH
368environment variable.
369.It Fl X
370Used with the
371.Fl F
372recovery option.
373Determines whether extreme measures to find a valid txg should take place.
374This allows the pool to
375be rolled back to a txg which is no longer guaranteed to be consistent.
376Pools imported at an inconsistent txg may contain uncorrectable
377checksum errors.
378For more details about pool recovery mode, see the
379.Fl F
380option, above.
381WARNING: This option can be extremely hazardous to the
382health of your pool and should only be used as a last resort.
383.It Fl T
384Specify the txg to use for rollback.
385Implies
386.Fl FX .
387For more details
388about pool recovery mode, see the
389.Fl X
390option, above.
391.Em WARNING :
392This option can be extremely hazardous to the
393health of your pool and should only be used as a last resort.
394.It Fl t
395Used with
396.Ar newpool .
397Specifies that
398.Ar newpool
399is temporary.
400Temporary pool names last until export.
401Ensures that the original pool name will be used
402in all label updates and therefore is retained upon export.
403Will also set
404.Fl o Sy cachefile Ns = Ns Sy none
405when not explicitly specified.
406.El
407.El
408.
409.Sh EXAMPLES
410.\" These are, respectively, examples 9 from zpool.8
411.\" Make sure to update them bidirectionally
412.Ss Example 9 : No Importing a ZFS Storage Pool
413The following command displays available pools, and then imports the pool
414.Ar tank
415for use on the system.
416The results from this command are similar to the following:
417.Bd -literal -compact -offset Ds
418.No # Nm zpool Cm import
419  pool: tank
420    id: 15451357997522795478
421 state: ONLINE
422action: The pool can be imported using its name or numeric identifier.
423config:
424
425        tank        ONLINE
426          mirror    ONLINE
427            sda     ONLINE
428            sdb     ONLINE
429
430.No # Nm zpool Cm import Ar tank
431.Ed
432.
433.Sh SEE ALSO
434.Xr zpool-export 8 ,
435.Xr zpool-list 8 ,
436.Xr zpool-status 8
437