NVMe

Install

sudo apt install -y nvme-cli

CLI

# list devices
nvme list
 
nvme smart-log /dev/nvme0n1
 
isdct show -d DeviceStatus,Index,Firmware,FirmwareUpdateAvailable -intelssd
 
# format
https://manpages.ubuntu.com/manpages/jammy/en/man1/nvme-format.1.html
nvme format --force /dev/nvmeXn1
blkdiscard --force /dev/nvmeXn1

Fix nvme1: ignoring ctrl due to duplicate subnqn
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1803692

# dmesg | grep nvme
[    2.546620] nvme nvme0: pci function 0000:5e:00.0
[    2.552447] nvme nvme1: pci function 0000:5f:00.0
[    2.768347] nvme nvme1: ignoring ctrl due to duplicate subnqn (nqn.2017-12.org.nvmexpress:uuid:11111111-2222-3333-4444-555555555555).
[    2.775422] nvme nvme1: Removing after probe failure status: -22
[    2.779813]  nvme0n1: p1 p2

Fix by upgrade NVMe firmware
http://www.panticz.de/intel/nvme

Delete

nvme format --ses=1 /dev/nvme1

Namespaces
https://www.linuxjournal.com/content/data-flash-part-ii-using-nvme-drives-and-creating-nvme-over-fabrics-network

# delete namespace
nvme delete-ns /dev/nvme0 -n 1
 
# get capacities
nvme id-ctrl /dev/nvme0 | grep mcap
 
# get 100% capacity
TNVMCAP=$(nvme id-ctrl /dev/nvme0 | grep tnvmcap | cut -d":" -f2)
echo $((TNVMCAP / 512))
 
# create 2TB namespace
nvme create-ns /dev/nvme0 -s 3907029168 -c 3907029168 -b 512
nvme attach-ns /dev/nvme0 --controllers=0 --namespace-id=1
nvme ns-rescan
# modprobe -r nvme, sudo sh -c "echo 1 > /sys/bus/pci/rescan"
 
 
nvme list
Node             SN                   Model                                    Namespace Usage                      Format           FW Rev  
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1     BTLJ934302G18P0HGN   INTEL SSDPE2KX080T8                      1           2.00  TB /   2.00  TB    512   B +  0 B   VDV10170
/dev/nvme0n2     BTLJ934302G18P0HGN   INTEL SSDPE2KX080T8                      2           2.00  TB /   2.00  TB    512   B +  0 B   VDV10170
/dev/nvme0n3     BTLJ934302G18P0HGN   INTEL SSDPE2KX080T8                      3           2.00  TB /   2.00  TB    512   B +  0 B   VDV10170
/dev/nvme0n4     BTLJ934302G18P0HGN   INTEL SSDPE2KX080T8                      4           2.00  TB /   2.00  TB    512   B +  0 B   VDV10170

Links
https://wiki.hetzner.de/index.php/NVMe
https://www.iol.unh.edu/sites/default/files/testsuites/nvme/NVMe_Interop_Test_Suite_v6.0.pdf
https://www.linuxjournal.com/content/data-flash-part-ii-using-nvme-drives-and-creating-nvme-over-fabrics-network