1NVME-ID-NS(1)                     NVMe Manual                    NVME-ID-NS(1)
2
3
4

NAME

6       nvme-id-ns - Send NVMe Identify Namespace, return result and structure
7

SYNOPSIS

9       nvme id-ns <device> [-v | --vendor-specific] [-b | --raw-binary]
10                           [--namespace-id=<nsid> | -n <nsid>] [--force]
11                           [--human-readable | -H]
12                           [--output-format=<fmt> | -o <fmt>]
13

DESCRIPTION

15       For the NVMe device given, sends an identify namespace command and
16       provides the result and returned structure.
17
18       The <device> parameter is mandatory and may be either the NVMe
19       character device (ex: /dev/nvme0), or a namespace block device (ex:
20       /dev/nvme0n1). If the character device is given, the '--namespace-id'
21       option is mandatory, otherwise it will use the ns-id of the namespace
22       for the block device you opened. For block devices, the ns-id used can
23       be overridden with the same option.
24
25       On success, the structure may be returned in one of several ways
26       depending on the option flags; the structure may be parsed by the
27       program or the raw buffer may be printed to stdout.
28

OPTIONS

30       -n <nsid>, --namespace-id=<nsid>
31           Retrieve the identify namespace structure for the given nsid. This
32           is required for the character devices, or overrides the block nsid
33           if given. If the controller supports namespace management
34           capability and 0xFFFFFFFF is given, then the controller returns the
35           identify namespace structure that specifies common capabilities
36           across namespaces for the controller.
37
38       --force
39           Request controller return the identify namespace structure even if
40           the namespace is not attached to the controller. This is valid only
41           for controllers at or newer than revision 1.2. Controllers at
42           revision lower than this may interpret the command incorrectly.
43
44       -b, --raw-binary
45           Print the raw buffer to stdout. Structure is not parsed by program.
46           This overrides the vendor specific and human readable options.
47
48       -v, --vendor-specific
49           In addition to parsing known fields, this option will dump the
50           vendor specific region of the structure in hex with ascii
51           interpretation.
52
53       -H, --human-readable
54           This option will parse and format many of the bit fields into
55           human-readable formats.
56
57       -o <format>, --output-format=<format>
58           Set the reporting format to normal, json, or binary. Only one
59           output format can be used at a time.
60

EXAMPLES

62       •   Has the program interpret the returned buffer and display the known
63           fields in a human readable format:
64
65               # nvme id-ns /dev/nvme0n1
66
67       •   If using the character device or overriding namespace id:
68
69               # nvme id-ns /dev/nvme0 -n 1
70               # nvme id-ns /dev/nvme0n1 -n 1
71               # nvme id-ns /dev/nvme0 --namespace-id=1
72
73       •   In addition to showing the known fields, have the program to
74           display the vendor unique field:
75
76               # nvme id-ns /dev/nvme0n1 --vendor-specific
77               # nvme id-ns /dev/nvme0n1 -v
78
79           The above will dump the 'vs' buffer in hex since it doesn’t know
80           how to interpret it.
81
82       •   Have the program return the raw structure in binary:
83
84               # nvme id-ns /dev/nvme0n1 --raw-binary > id_ns.raw
85               # nvme id-ns /dev/nvme0n1 -b > id_ns.raw
86
87           It is probably a bad idea to not redirect stdout when using this
88           mode.
89
90       •   Alternatively you may want to send the data to another program that
91           can parse the raw buffer.
92
93               # nvme id-ns /dev/nvme0n1 --raw-binary | nvme_parse_id_ns
94
95           The parse program in the above example can be a program that shows
96           the structure in a way you like. The following program is such an
97           example that will parse it and can accept the output through a
98           pipe, '|', as shown in the above example, or you can 'cat' a saved
99           output buffer to it.
100
101           /* File: nvme_parse_id_ns.c */
102
103           #include <linux/nvme.h>
104           #include <stdio.h>
105           #include <unistd.h>
106
107           int main(int argc, char **argv)
108           {
109                   unsigned char buf[sizeof(struct nvme_id_ns)];
110                   struct nvme_id_ns *ns = (struct nvme_id_ns *)buf;
111
112                   if (read(STDIN_FILENO, buf, sizeof(buf)))
113                           return 1;
114
115                   printf("nsze : %#llx\n", ns->nsze);
116                   printf("ncap : %#llx\n", ns->ncap);
117                   return 0;
118           }
119

NVME

121       Part of the nvme-user suite
122
123
124
125NVMe                              09/29/2023                     NVME-ID-NS(1)
Impressum