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 createor destroycommands. 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 DIMMs 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)>
A nmemX device name, or a dimm id number. Restrict the operation to the specified dimm(s). The keyword all can be specified to
indicate the lack of any restriction, however this is the same as not supplying a --dimm option at all.
-s, --size=
Limit the operation to the given number of bytes. A size of 0 indicates to operate over the entire label capacity.
-O, --offset=
Begin the operation at the given offset into the label area.
-b, --bus=
A bus id number, or a provider string (e.g. "ACPI.NFIT"). Restrict the operation to the specified bus(es). The keyword all can be
specified to indicate the lack of any restriction, however this is the same as not supplying a --bus option at all.
-v
Turn on verbose debug messages in the library (if ndctl was built with logging and debug enabled).
-I, --index
Limit the span of the label operation to just the index-block area. This is useful to determine if the dimm label area is
initialized. Note that this option and --size/--offset are mutually exclusive.
-o, --output
output file
-j, --json
parse the label data into json assuming the NVDIMM Namespace Specification format.
-u, --human
enable json output and convert number formats to human readable strings, for example show the size in terms of "KB", "MB", "GB", etc
instead of a signed 64-bit numbers per the JSON interchange format (implies --json).
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.