Amazon Ad

Featured Post

Showing posts with label nvme. Show all posts
Showing posts with label nvme. Show all posts

Sunday, December 23, 2018

How to format an NVMe drive

To understand the little things in life: https://whatsdathing.blogspot.com/


The following are concise instructions on how to format NVMe drives in Linux.

First, identify the format required:

nvme id-ns /dev/nvme1n1 | grep LBA
LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0x1 Better 
LBA Format  1 : Metadata Size: 8   bytes - Data Size: 512 bytes - Relative Performance: 0x3 Degraded 
LBA Format  2 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0 Best  (in use)
LBA Format  3 : Metadata Size: 8   bytes - Data Size: 4096 bytes - Relative Performance: 0x2 Good

Explanation


  • Each format has an id: 0, 1, 2, 3 in this example.
  • There are two data sector sizes - 512 bytes and 4K. Typically the 4K formats provide the best performance and endurance.
  • Metadata - some drives provide the capability to add a few bytes for additional metadata for each sector. This is typically used for T10/DIF CRC.

Format

nvme format /dev/nvme1n1 -l 0

where l represents the LBA format id as listed in nvme id-ns.

Identify NVMe Drive Attribute


[root@moon 14:27:11 john]# nvme id-ns -H /dev/nvme1n1
NVME Identify Namespace 1:
nsze    : 0xba4d9d6
ncap    : 0xba4d9d6
nuse    : 0xba4d9d6
nsfeat  : 0
  [2:2] : 0 Deallocated or Unwritten Logical Block error Not Supported
  [1:1] : 0 Namespace uses AWUN, AWUPF, and ACWU
  [0:0] : 0 Thin Provisioning Not Supported

nlbaf   : 3
flbas   : 0x3
  [4:4] : 0 Metadata Transferred in Separate Contiguous Buffer
  [3:0] : 0x3 Current LBA Format Selected

mc      : 0x3
  [1:1] : 0x1 Metadata Pointer Supported
  [0:0] : 0x1 Metadata as Part of Extended Data LBA Supported

dpc     : 0x1f
  [4:4] : 0x1 Protection Information Transferred as Last 8 Bytes of Metadata Supported
  [3:3] : 0x1 Protection Information Transferred as First 8 Bytes of Metadata Supported
  [2:2] : 0x1 Protection Information Type 3 Supported
  [1:1] : 0x1 Protection Information Type 2 Supported
  [0:0] : 0x1 Protection Information Type 1 Supported

dps     : 0
  [3:3] : 0 Protection Information is Transferred as Last 8 Bytes of Metadata
  [2:0] : 0 Protection Information Disabled

nmic    : 0x1
  [0:0] : 0x1 Namespace Multipath Capable

rescap  : 0x7f
  [6:6] : 0x1 Exclusive Access - All Registrants Supported
  [5:5] : 0x1 Write Exclusive - All Registrants Supported
  [4:4] : 0x1 Exclusive Access - Registrants Only Supported
  [3:3] : 0x1 Write Exclusive - Registrants Only Supported
  [2:2] : 0x1 Exclusive Access Supported
  [1:1] : 0x1 Write Exclusive Supported
  [0:0] : 0x1 Persist Through Power Loss Supported

fpi     : 0x80
  [7:7] : 0x1 Format Progress Indicator Supported
  [6:0] : 0 Format Progress Indicator (Remaining 0%)

dlfeat  : 0
  [4:4] : 0 Guard Field of Deallocated Logical Blocks is set to 0xFFFF
  [3:3] : 0 Deallocate Bit in the Write Zeroes Commmand is Not Supported
  [2:0] : 0 Bytes Read From a Deallocated Logical Block and its Metadata are Not Reported

nawun   : 0
nawupf  : 0
nacwu   : 0
nabsn   : 0
nabo    : 0
nabspf  : 0
noiob   : 0
nvmcap  : 800166076416
nvmsetid: 0
endgid  : 0
nguid   : 334843304bd021179843285800000004
eui64   : 023438ec7dbc1f9d
LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0x1 Better 
LBA Format  1 : Metadata Size: 8   bytes - Data Size: 512 bytes - Relative Performance: 0x3 Degraded 
LBA Format  2 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0 Best  (in use)
LBA Format  3 : Metadata Size: 8   bytes - Data Size: 4096 bytes - Relative Performance: 0x2 Good