ZFS_PREPARE_DISK(8)

πŸ’– zfs_prepare_disk(8) πŸ’–

okay bestie, gather round, because this one is a script, and it's the glow-up station your disks visit before they get to join the pool. it lives in section 8 of the System Manager's Manual, and honestly? she's optional but she's iconic. πŸŽ€


✨ NAME ✨

zfs_prepare_disk β€” the special little script that gets run before bringing a disk into a pool. like, the pre-game ritual. the outfit check. the vibe check before the disk walks into the party. πŸ¦‹


🌸 DESCRIPTION 🌸

so here's the tea: zfs_prepare_disk is an optional script that gets called by libzfs before bringing a disk into a pool. it's yours to modify, bestie β€” you can make it run literally whatever commands are necessary to get a disk ready for inclusion into the pool. no cap. πŸ™ˆ

wanna update the drive's firmware? wanna check the drive's health? just add lines to zfs_prepare_disk and it's handled. it's giving personal assistant energy. πŸ’…

and because she's optional, she can absolutely be removed if you don't need her β€” no hard feelings, no drama. libzfs will look for the script at:

/usr/lib/zfs-linux/zfs_prepare_disk

that's her address. that's where she hangs out. πŸ‘‘

🧚 Properties 🧚

zfs_prepare_disk gets passed the following environment variables β€” think of them as the little notes she gets handed on her way in:

  • POOL_NAME β€” Name of the pool. πŸ’œ
  • VDEV_PATH β€” Path to the disk (like /dev/sda).
  • VDEV_PREPARE β€” Reason why the disk is being prepared for inclusion ('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 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.
not me needing to say this but: some of these variables may have a blank value. POOL_NAME is blank at pool creation time, for example. so like, don't be shocked when it ghosts you. 😭

🌈 ENVIRONMENT 🌈

zfs_prepare_disk runs with a limited $PATH. that's it, that's the whole vibe. plan accordingly, bestie. ✨


⭐ EXIT STATUS ⭐

zfs_prepare_disk should return 0 on success, non-zero otherwise.

and if non-zero is returned, the disk will not be included in the pool. no invite, no party, no pool. fr fr. πŸ’€

and that's the whole page, bestie 🫢 β€” this gem came from OpenZFS, dated August 30, 2023, and it's your System Manager's Manual serving it up in section 8. slay, go prepare some disks, and remember: return 0 or the disk stays outside. periodt. πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from