The namespace label area is a small persistent partition of capacity available on some NVDIMM devices. The label area is used to store the definition of any NVDIMM namespaces.
The labels on the NVDIMMs cannot be edited directly. Changing the configuration can be achieved using the ndctl create or destroy commands. See Managing Namespaces and Managing Regions. ndctl provides several label related commands shown below:
check-labels - determine if the given dimm(s) have a valid namespace index block
init-labels - initialize the label data area on a dimm or set of dimms
read-labels - read out the label area on a dimm or set of dimms
write-labels - write data to the label area on a dimm
zero-labels - zero out the label area on a dimm or set of dimms
Checking Labels
The check-labels command validates the index block within the label storage area on the specified NVDIMMs. If issues are found, running the command in verbose mode using the -v option, reports the reason the index block is deemed invalid.
usage: ndctl check-labels <nmem0> [<nmem1>..<nmemN>] [<options>]
-b, --bus <bus-id> <nmem> must be on a bus with an id/provider of <bus-id>
-v, --verbose turn on debug
1) Identify the NVDIMMs (nmem's) in the host using the ndctl list -D command:
To display more information, if available, use the -v option:
# ndctl check-labels nmem3 -v
Note: The -v option may not produce any additional information if the labels are valid or ndctl was not built with logging or debug options.
Initializing Labels
This command can be used to initialize the namespace index block if it is missing or reinitialize it if it is damaged or was previously zero'd. Note that reinitialization effectively destroys all existing namespace labels on the DIMM.
This is an expert mode operation. Overwriting labels will cause data loss. Backup all data prior to overwriting labels.
usage: ndctl init-labels <nmem0> [<nmem1>..<nmemN>] [<options>]
-b, --bus <bus-id> <nmem> must be on a bus with an id/provider of <bus-id>
-v, --verbose turn on debug
-f, --force force initialization even if existing index-block present
-V, --label-version <version-number>
namespace label specification version (default: 1.1)
Before initializing the labels, all namespaces and regions must be destroyed or disabled. A warning message is displayed when attempting to initialize labels on active regions.
# ndctl init-labels nmem3 nmem2
nmem3: regions active, abort label write
nmem2: regions active, abort label write
1) Identify the active/enabled NVDIMM devices, Regions, and Namespaces
6) New namespaces can now be created on the regions. See Managing Namespaces for more information.
Reading Labels
The read-labels command dumps the data in a dimm’s label area to stdout or a file in raw or JSON format. When multiple dimms (nmem's) are specified, the data is concatenated.
Usage:
ndctl read-labels <nmem0> [<nmem1>..<nmemN>] [<options>]
OPTIONS
<memory device(s)>
One or more nmemX device names. The keyword all can be specified to operate on every dimm in the system, optionally
filtered by bus id (see --bus= option).
-b, --bus=
Limit operation to memory devices (dimms) that are on the given bus. Where bus can be a provider name or a bus id
number.
-v
Turn on verbose debug messages in the library (if ndctl was built with logging and debug enabled).
-o, --output
output file
-j, --json
parse the label data into json assuming the NVDIMM Namespace Specification format.
The following shows a label from nvdimm0 (nmem0) printed to stdout in JSON format.
To backup an NVDIMM label using the raw format, use:
# ndctl read-labels nmem0 > nmem0.lsa
Writing Labels
This is an expert mode operation. Overwriting labels will cause data loss. Backup all data prior to overwriting labels.
Writing labels overwrites the current label with the contents of the specified file, or stdin, collected from a read-labels operation from a different label, or a previous label backup.
Read data from the input filename, or stdin, and write it to the given device. The device being written to must not be active in any region, otherwise the kernel will not allow write access to the device’s label data area.
The following shows how a raw label from an active nvdimm can be written to an inactive nvdimm.