xref: /freebsd/sys/contrib/openzfs/man/man8/zfs_prepare_disk.8.in (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1.\" SPDX-License-Identifier: CDDL-1.0
2.\"
3.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049).
4.\" Copyright (C) 2023 Lawrence Livermore National Security, LLC.
5.\" Refer to the OpenZFS git commit log for authoritative copyright attribution.
6.\"
7.\" The contents of this file are subject to the terms of the
8.\" Common Development and Distribution License Version 1.0 (CDDL-1.0).
9.\" You can obtain a copy of the license from the top-level file
10.\" "OPENSOLARIS.LICENSE" or at <http://opensource.org/licenses/CDDL-1.0>.
11.\" You may not use this file except in compliance with the license.
12.\"
13.\" Developed at Lawrence Livermore National Laboratory (LLNL-CODE-403049)
14.\"
15.Dd August 30, 2023
16.Dt ZFS_PREPARE_DISK 8
17.Os
18.
19.Sh NAME
20.Nm zfs_prepare_disk
21.Nd special script that gets run before bringing a disk into a pool
22.Sh DESCRIPTION
23.Nm
24is an optional script that gets called by libzfs before bringing a disk into a
25pool.
26It can be modified by the user to run whatever commands are necessary to prepare
27a disk for inclusion into the pool.
28For example, users can add lines to
29.Nm zfs_prepare_disk
30to do things like update the drive's firmware or check the drive's health.
31.Nm zfs_prepare_disk
32is optional and can be removed if not needed.
33libzfs will look for the script at @zfsexecdir@/zfs_prepare_disk.
34.
35.Ss Properties
36.Nm zfs_prepare_disk
37will be passed the following environment variables:
38.sp
39.Bl -tag -compact -width "VDEV_ENC_SYSFS_PATH"
40.
41.It Nm POOL_NAME
42.No Name of the pool
43.It Nm VDEV_PATH
44.No Path to the disk (like /dev/sda)
45.It Nm VDEV_PREPARE
46.No Reason why the disk is being prepared for inclusion
47('create', 'add', 'replace', or 'autoreplace').
48This can be useful if you only want the script to be run under certain actions.
49.It Nm VDEV_UPATH
50.No Path to one of the underlying devices for the
51disk.
52For multipath this would return one of the /dev/sd* paths to the disk.
53If the device is not a device mapper device, then
54.Nm VDEV_UPATH
55just returns the same value as
56.Nm VDEV_PATH
57.It Nm VDEV_ENC_SYSFS_PATH
58.No Path to the disk's enclosure sysfs path, if available
59.El
60.Pp
61Note that some of these variables may have a blank value.
62.Nm POOL_NAME
63is blank at pool creation time, for example.
64.Sh ENVIRONMENT
65.Nm zfs_prepare_disk
66runs with a limited $PATH.
67.Sh EXIT STATUS
68.Nm zfs_prepare_disk
69should return 0 on success, non-zero otherwise.
70If non-zero is returned, the disk will not be included in the pool.
71.
72