ZFS\_PREPARE\_DISK(8) System Manager's Manual ZFS\_PREPARE\_DISK(8)

# [NAME](#NAME)

`zfs_prepare_disk` — special script that gets run before bringing a disk into a pool

# [DESCRIPTION](#DESCRIPTION)

`zfs_prepare_disk` is an optional script that gets called by libzfs before bringing a disk into a pool. It can be modified by the user to run whatever commands are necessary to prepare a disk for inclusion into the pool. For example, users can add lines to `zfs_prepare_disk` to do things like update the drive's firmware or check the drive's health. `zfs_prepare_disk` is optional and can be removed if not needed. libzfs will look for the script at /usr/lib/zfs/zfs\_prepare\_disk.

## [Properties](#Properties)

`zfs_prepare_disk` will be passed the following environment variables:

`POOL_NAME`

[Name of the pool](#Name)

`VDEV_PATH`

[Path to the disk (like /dev/sda)](#Path)

`VDEV_PREPARE`

[Reason why the disk is being prepared for inclusion](#Reason) ('create', 'add', 'replace', or 'autoreplace'). This can be useful if you only want the script to be run under certain actions.

`VDEV_UPATH`

[Path to one of the underlying devices for the](#Path~2) disk. For multipath this would return one of the /dev/sd* paths to the disk. If the device is not a device mapper device, then `VDEV_UPATH` just returns the same value as `VDEV_PATH`

`VDEV_ENC_SYSFS_PATH`

[Path to the disk's enclosure sysfs path, if available](#Path~3)

Note that some of these variables may have a blank value. `POOL_NAME` is blank at pool creation time, for example.

# [ENVIRONMENT](#ENVIRONMENT)

`zfs_prepare_disk` runs with a limited $PATH.

# [EXIT STATUS](#EXIT_STATUS)

`zfs_prepare_disk` should return 0 on success, non-zero otherwise. If non-zero is returned, the disk will not be included in the pool.

August 30, 2023 OpenZFS

---

Document: zfs_prepare_disk(8) from zfs 2.4.4-r3 (Chainguard OS)
Source: https://github.com/openzfs/zfs
