1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
'\" t
.\" Title: nvme-format
.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 04/24/2020
.\" Manual: NVMe Manual
.\" Source: NVMe
.\" Language: English
.\"
.TH "NVME\-FORMAT" "1" "04/24/2020" "NVMe" "NVMe Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
nvme-format \- Format an NVMe device
.SH "SYNOPSIS"
.sp
.nf
\fInvme format\fR <device> [\-\-namespace\-id=<nsid> | \-n <nsid>]
[\-\-lbaf=<lbaf> | \-l <lbaf>]
[\-\-block\-size=<block size | \-b <block size>]
[\-\-ses=<ses> | \-s <ses>]
[\-\-pil=<pil> | \-p <pil>]
[\-\-pi=<pi> | \-i <pi>]
[\-\-ms=<ms> | \-m <ms>]
[\-\-reset | \-r ]
[\-\-force | \-f ]
[\-\-timeout=<timeout> | \-t <timeout> ]
.fi
.SH "DESCRIPTION"
.sp
For the NVMe device given, send an nvme Format Namespace admin command and provides the results\&.
.sp
The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the character device is given, and the controller does not support formatting of particular namespaces (ID_CTRL\&.FNA bit 0 enabled), then all namespaces will be formatted\&. If FNA is disabled, then the namespace identifier must be specified with the \fInamespace\-id\fR option; specify a value of 0xffffffff to send the format to all namespaces\&. If the block device is given, the namespace identifier will default to the namespace ID of the block device given, but can be overridden with the same option\&.
.sp
Note, the numeric suffix on the character device, for example the \fI0\fR in /dev/nvme0, does NOT indicate this device handle is the parent controller of any namespaces with the same suffix\&. The namespace handle\(cqs numeral may be coming from the subsystem identifier, which is independent of the controller\(cqs identifier\&. Do not assume any particular device relationship based on their names\&. If you do, you may irrevocably erase data on an unintended device\&.
.sp
On success, the program will automatically issue BLKRRPART ioctl to force rescanning the namespaces\&. If the driver is recent enough, this will automatically update the physical block size\&. If it is not recent enough, you will need to remove and rescan your device some other way for the new block size to be visible, if the size was changed with this command\&.
.SH "OPTIONS"
.PP
\-n <nsid>, \-\-namespace\-id=<nsid>
.RS 4
Send the format command for the specified nsid\&. This can be used to override the default value for either character device (unspecified) or the block device (result from NVME_IOCTL_ID)\&.
.RE
.PP
\-l <lbaf>, \-\-lbaf=<lbaf>
.RS 4
LBA Format: This field specifies the LBA format to apply to the NVM media\&. This corresponds to the LBA formats indicated in the Identify Namespace command\&. Conflicts with \-\-block\-size argument\&. Defaults to 0\&.
.RE
.PP
\-b <block size>, \-\-block\-size=<block size>
.RS 4
Block Size: This field is used to specify the target block size to format to\&. Potential lbaf values will be scanned and the lowest numbered will be selected for the format operation\&. Conflicts with \-\-lbaf argument\&.
.RE
.PP
\-s <ses>, \-\-ses=<ses>
.RS 4
Secure Erase Settings: This field specifies whether a secure erase should be performed as part of the format and the type of the secure erase operation\&. The erase applies to all user data, regardless of location (e\&.g\&., within an exposed LBA, within a cache, within deallocated LBAs, etc)\&. Defaults to 0\&.
.TS
allbox tab(:);
lt lt
lt lt
lt lt
lt lt
lt lt.
T{
Value
T}:T{
Definition
T}
T{
0
T}:T{
No secure erase operation requested
T}
T{
1
T}:T{
User Data Erase: All user data shall be erased, contents of the user data after the erase is indeterminate (e\&.g\&., the user data may be zero filled, one filled, etc)\&. The controller may perform a cryptographic erase when a User Data Erase is requested if all user data is encrypted\&.
T}
T{
2
T}:T{
Cryptographic Erase: All user data shall be erased cryptographically\&. This is accomplished by deleting the encryption key\&.
T}
T{
3\(en7
T}:T{
Reserved
T}
.TE
.sp 1
.RE
.PP
\-p <pil>, \-\-pil=<pil>
.RS 4
Protection Information Location: If set to \(oq1\(cq and protection information is enabled, then protection information is transferred as the first eight bytes of metadata\&. If cleared to \(oq0\(cq and protection information is enabled, then protection information is transferred as the last eight bytes of metadata\&. Defaults to 0\&.
.RE
.PP
\-i <pi>, \-\-pi=<pi>
.RS 4
Protection Information: This field specifies whether end\-to\-end data protection is enabled and the type of protection information\&. Defaults to 0\&.
.TS
allbox tab(:);
lt lt
lt lt
lt lt
lt lt
lt lt
lt lt.
T{
Value
T}:T{
Definition
T}
T{
0
T}:T{
Protection information is not enabled
T}
T{
1
T}:T{
Protection information is enabled, Type 1
T}
T{
2
T}:T{
Protection information is enabled, Type 2
T}
T{
3
T}:T{
Protection information is enabled, Type 3
T}
T{
4\(en7
T}:T{
Reserved
T}
.TE
.sp 1
.RE
.PP
\-m <ms>, \-\-ms=<ms>
.RS 4
Metadata Settings: This field is set to \(oq1\(cq if the metadata is transferred as part of an extended data LBA\&. This field is cleared to \(oq0\(cq if the metadata is transferred as part of a separate buffer\&. The metadata may include protection information, based on the Protection Information (PI) field\&. Defaults to 0\&.
.RE
.PP
\-r, \-\-reset
.RS 4
Issue a reset after successful format\&. Must use the character device for this\&.
.RE
.PP
\-f, \-\-force
.RS 4
Just send the command immediately without warning of the implications\&.
.RE
.PP
\-t <timeout>, \-\-timeout=<timeout>
.RS 4
Override default timeout value\&. In milliseconds\&.
.RE
.SH "EXAMPLES"
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Format the device using all defaults:
.sp
.if n \{\
.RS 4
.\}
.nf
# nvme format /dev/nvme0n1
.fi
.if n \{\
.RE
.\}
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
Format namespace 1 with user data secure erase settings and protection information:
.sp
.if n \{\
.RS 4
.\}
.nf
# nvme format /dev/nvme0 \-\-namespace\-id=1 \-\-ses=1 \-\-pi=1
.fi
.if n \{\
.RE
.\}
.RE
.SH "NVME"
.sp
Part of the nvme\-user suite
|