I am trying to understand the configuration of nvme.
But I do not understand why there are two devices: nvme block and nvme character device:
crw------- 1 root root 243, 0 Dec 12 16:09 /dev/nvme0
brw-rw---- 1 root disk 259, 0 Jan 14 01:30 /dev/nvme0n1
What is the purpose of each or when to use them?
The character device
/dev/nvme0
is the NVME device controller, and block devices like/dev/nvme0n1
are the NVME storage namespaces: the devices you use for actual storage, which will behave essentially as disks.In enterprise-grade hardware, there might be support for several namespaces, thin provisioning within namespaces and other features. For now, you could think namespaces as sort of meta-partitions with extra features for enterprise use.
Think of namespaces as partitions that don't go away when you secure erase the SSD. The controller and namespace(s) are separate. Namespaces can be shared, and can allow remote controllers to access them. Companies like Excelero or Lightbits leverage this technology with their product offerings I believe.
In large devices, say 15TB NVME, you may want to carve the SSD up into 3 separate pieces for different purposes (Cache on /dev/nvme0n1, Database on /dev/nvme0n2, VM storage on /dev/nvme0n3). You could create 3 equal or unequal sized name spaces and use those on each /dev/nvme0n_ device. Any space left over goes to over provisioned capacity which has its own benefits.