NVMe Low-Level Format

NVMe devices store data in configurable sized blocks. Simplyblock expects NVMe devices to provide 4 KB block internal block size. Hence, to prevent data loss in case of a sudden power outage, NVMe devices must be formatted for a specific LBA format.

Danger

Failing to format NVMe devices with the correct LBA format can lead to data loss or data corruption in the case of a sudden power outage or other loss of power.

The lsblk is the best way to find all NVMe devices attached to a system.

Example output of lsblk
[demo@demo-3 ~]# sudo lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda           8:0    0   30G  0 disk
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   29G  0 part
  ├─rl-root 253:0    0   26G  0 lvm  /
  └─rl-swap 253:1    0    3G  0 lvm  [SWAP]
nvme3n1     259:0    0  6.5G  0 disk
nvme2n1     259:1    0   70G  0 disk
nvme1n1     259:2    0   70G  0 disk
nvme0n1     259:3    0   70G  0 disk

In the example, we see four NVMe devices. Three devices of 70GiB and one device with 6.5GiB storage capacity.

To find the correct LBA format (lbaf) for each of the devices, the nvme cli can be used.

Show NVMe namespace information
sudo nvme id-ns /dev/nvmeXnY

The output depends on the NVMe device itself, but looks something like this:

Example output of NVMe namespace information
[demo@demo-3 ~]# sudo nvme id-ns /dev/nvme0n1
NVME Identify Namespace 1:
...
lbaf  0 : ms:0   lbads:9  rp:0
lbaf  1 : ms:8   lbads:9  rp:0
lbaf  2 : ms:16  lbads:9  rp:0
lbaf  3 : ms:64  lbads:9  rp:0
lbaf  4 : ms:0   lbads:12 rp:0 (in use)
lbaf  5 : ms:8   lbads:12 rp:0
lbaf  6 : ms:16  lbads:12 rp:0
lbaf  7 : ms:64  lbads:12 rp:0

From this output, the required lbaf configuration can be found. The necessary configuration has to have the following values:

Property Value
ms 0
lbads 12
rp 0

In the example, the required LBA format is 4. If a NVMe device doesn't have that combination, any other lbads=12 combination will work. However, simplyblock recommends to ask for the best available combination.

In our example, the device is already formatted with the correct lbaf (see the "in use"). It is, however, recommended to always format the device before use.

To format the drive, the nvme cli is used again.

Formatting the NVMe device
sudo nvme format --lbaf=<lbaf> --ses=0 /dev/nvmeXnY

The output of the command should give a successful response when executing similar to the below example.

Example output of NVMe device formatting
[demo@demo-3 ~]# sudo nvme format --lbaf=4 --ses=0 /dev/nvme0n1
You are about to format nvme0n1, namespace 0x1.
WARNING: Format may irrevocably delete this device's data.
You have 10 seconds to press Ctrl-C to cancel this operation.

Use the force [--force] option to suppress this warning.
Sending format operation ...
Success formatting namespace:1

Warning

This operation needs to be repeated for each NVMe device that will be handled by simplyblock.