I want to use NVMe overprovisioning on a NVMe disk with ZFS. I have read this: https://openzfs.github.io/openzfs-docs/Performance%20and%20Tuning/Workload%20Tuning.html?highlight=ashift#nvme-overprovisioning
But I don't understand the "Create a new namespace of size 4GB." step. How is it done? Do it mean to create a 4GB partition?
While it's possible to achieve overprovisioning by partitioning less than a full device, creating a namespace on an nvme is different from creating a partition. The OS will see a namespace as a device. If you create multiple namspaces on an NVMe drive, the OS will see multiple devices and can create an independent partition table on each device.
This is useful in a multitenant environment where you may want to expose only certain namespaces to a tenant. It can also be useful if your OS installer uses the whole device and doesn't give you the option of overprovisioning by creating smaller partitions. The ESXi installer does this, and I think Truenas as well. In these cases, overprovisioning with a namespace prevents the installer from claiming the whole drive.
If the above cases don't apply to you then you can overprovision with your partitions. However if you want to use namespaces to overprovision an NVMe device, then here is how you might go about it. Note that this is only possible if the NVMe device supports more than one namespaces. Many devices support only a single namespace, and if this is the case, you won't be able to use it to overprovision the device.
The examples below assume your device is /dev/nvme0 and that it supports 4k sectors.
Check how many namespaces the device supports.
nvme id-ctrl /dev/nvme0 | grep ^nnIf it returns '1', you can't delete or create namespaces on the device. If more than one, continue by deleting the first namespace.
nvme delete-ns /dev/nvme0 -n 1Create a new namespace 4GB in size with 4k sectors.
nvme create-ns /dev/nvme0 -b 4096 -s 4194304There are many great resources for learning more about nvme-cli and how to manage your NVMe devices. I referenced the following pages for the information I provided above.
https://narasimhan-v.github.io/2020/06/12/Managing-NVMe-Namespaces.html https://www.drewthorst.com/posts/nvme/namespaces/readme/