Persistent device naming for NVMe storage devices

block-devicedevicesstorage

The Linux kernel's simple naming for a storage device (e.g. /dev/sda, /dev/sdb) can change randomly across boots. Is that true for NVMe storage devices too? These have names such as /dev/nvme0n1p1 and /dev/nvme0n1p2, etc.

Best Answer

Short: No. You can not rely on the name of the descriptor. And you most likely never will.

The NVMe naming standard describes:

  • nvme0: first registered device's device controller
  • nvme0n1: first registered device's first namespace
  • nvme0n1p1: first registered device's first namespace's first partition

So the overall naming is depended on your physical layout. And that can change depending on you use case by adding/removing block devices, drive failures, etc.

Basically the same as with the sd_ descriptors.

What you can rely on is the order of the listed partitions for each device, as those are getting stored on and read from the block device' partition table. As long as you do not change the partition layout, the order stays the same.

In the end, referring to either to the device UUID or PARTUUID is still the best practise, even with NVMe. Depending on the use case, referring to the LABEL might be more convenient.

Related Question