1NVME-ID-NS(1) NVMe Manual NVME-ID-NS(1)
2
3
4
6 nvme-id-ns - Send NVMe Identify Namespace, return result and structure
7
9 nvme id-ns <device> [-v | --vendor-specific] [-b | --raw-binary]
10 [--namespace-id=<nsid> | -n <nsid>] [-f | --force]
11 [--human-readable | -H]
12 [--output-format=<fmt> | -o <fmt>]
13
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
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.
34
35 -f, --force
36 Request controller return the indentify namespace structure even if
37 the namespace is not attached to the controller. This is valid only
38 for controllers at or newer than revision 1.2. Controllers at
39 revision lower than this may interpret the command incorrectly.
40
41 -b, --raw-binary
42 Print the raw buffer to stdout. Structure is not parsed by program.
43 This overrides the vendor specific and human readable options.
44
45 -v, --vendor-specific
46 In addition to parsing known fields, this option will dump the
47 vendor specific region of the structure in hex with ascii
48 interpretation.
49
50 -H, --human-readable
51 This option will parse and format many of the bit fields into
52 human-readable formats.
53
54 -o <format>, --output-format=<format>
55 Set the reporting format to normal, json, or binary. Only one
56 output format can be used at a time.
57
59 · Has the program interpret the returned buffer and display the known
60 fields in a human readable format:
61
62 # nvme id-ns /dev/nvme0n1
63
64 · If using the character device or overriding namespace id:
65
66 # nvme id-ns /dev/nvme0 -n 1
67 # nvme id-ns /dev/nvme0n1 -n 1
68 # nvme id-ns /dev/nvme0 --namespace-id=1
69
70 · In addition to showing the known fields, have the program to
71 display the vendor unique field:
72
73 # nvme id-ns /dev/nvme0n1 --vendor-specific
74 # nvme id-ns /dev/nvme0n1 -v
75
76 The above will dump the 'vs' buffer in hex since it doesn’t know
77 how to interpret it.
78
79 · Have the program return the raw structure in binary:
80
81 # nvme id-ns /dev/nvme0n1 --raw-binary > id_ns.raw
82 # nvme id-ns /dev/nvme0n1 -b > id_ns.raw
83
84 It is probably a bad idea to not redirect stdout when using this
85 mode.
86
87 · Alternatively you may want to send the data to another program that
88 can parse the raw buffer.
89
90 # nvme id-ns /dev/nvme0n1 --raw-binary | nvme_parse_id_ns
91
92 The parse program in the above example can be a program that shows
93 the structure in a way you like. The following program is such an
94 example that will parse it and can accept the output through a
95 pipe, '|', as shown in the above example, or you can 'cat' a saved
96 output buffer to it.
97
98 /* File: nvme_parse_id_ns.c */
99
100 #include <linux/nvme.h>
101 #include <stdio.h>
102 #include <unistd.h>
103
104 int main(int argc, char **argv)
105 {
106 unsigned char buf[sizeof(struct nvme_id_ns)];
107 struct nvme_id_ns *ns = (struct nvme_id_ns *)buf;
108
109 if (read(STDIN_FILENO, buf, sizeof(buf)))
110 return 1;
111
112 printf("nsze : %#llx\n", ns->nsze);
113 printf("ncap : %#llx\n", ns->ncap);
114 return 0;
115 }
116
118 Part of the nvme-user suite
119
120
121
122NVMe 06/05/2018 NVME-ID-NS(1)