Skip to content

Instantly share code, notes, and snippets.

@lidopaglia
Created August 7, 2021 16:16
Show Gist options
  • Save lidopaglia/f2c001dcd2771893e3b0d72707c9cc39 to your computer and use it in GitHub Desktop.
Save lidopaglia/f2c001dcd2771893e3b0d72707c9cc39 to your computer and use it in GitHub Desktop.
nvme

NVMe

Recently purchased two NVMe SSD disks. The Corsair Force MP600 and the Inland Premium 2TB. Installed in a desktop running Ubuntu 20.04.2 LTS.

First, installed nvme-cli tools. Userspace tooling to control NVMe drives:

sudo apt install nvme-cli

Now we can list the nvme on the system:

lido@tower:~$ sudo nvme list
Node             SN                   Model                                    Namespace Usage                      Format           FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1     21118230000128562430 Force MP600                              1           2.00  TB /   2.00  TB    512   B +  0 B   EGFM13.0
/dev/nvme1n1     21032520480143       PCIe SSD                                 1           2.05  TB /   2.05  TB    512   B +  0 B   ECFM13.3

Note that the format size was 512B by default.

Per the Arch Wiki I learned I could format each nvme with LBA 4096 for better performance.

first, had to check if the nvme would support this. Using nvme-cli I ran the identify namespace command for the MP600:

sudo nvme id-ns -H /dev/nvme0n1

Note the last two lines describe the lba format of 512 as the default and current format. But there is a 4096 option.

lido@tower:~$ sudo nvme id-ns -H /dev/nvme0n1
NVME Identify Namespace 1:
nsze    : 0xe8e088b0
ncap    : 0xe8e088b0
nuse    : 0xe8e088b0
nsfeat  : 0
  [4:4] : 0	NPWG, NPWA, NPDG, NPDA, and NOWS are Not Supported
  [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   : 1
flbas   : 0
  [4:4] : 0	Metadata Transferred in Separate Contiguous Buffer
  [3:0] : 0	Current LBA Format Selected

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

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

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

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

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

fpi     : 0
  [7:7] : 0	Format Progress Indicator Not Supported

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

nawun   : 0
nawupf  : 0
nacwu   : 0
nabsn   : 0
nabo    : 0
nabspf  : 0
noiob   : 0
nvmcap  : 2000398934016
nsattr	: 0
nvmsetid: 0
anagrpid: 0
endgid  : 0
nguid   : 00000000000000000000000000000000
eui64   : 6479a749102010b0
LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0x2 Good (in use)
LBA Format  1 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0x1 Better

Reading up on this I found that I should probably move these to be 4k? Since MIN-IO, OPT-IO, PHY-SEC, and LOG-SEC are all 512.

lido@tower:~$ lsblk -t
NAME                      ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED       RQ-SIZE  RA WSAME
loop0                             0    512      0     512     512    0 mq-deadline     256 128    0B
loop1                             0    512      0     512     512    0 mq-deadline     256 128    0B
loop2                             0    512      0     512     512    0 mq-deadline     256 128    0B
loop3                             0    512      0     512     512    0 mq-deadline     256 128    0B
loop4                             0    512      0     512     512    0 mq-deadline     256 128    0B
loop5                             0    512      0     512     512    0 mq-deadline     256 128    0B
sda                               0    512      0     512     512    0 mq-deadline      64 128    0B
├─sda1                            0    512      0     512     512    0 mq-deadline      64 128    0B
├─sda2                            0    512      0     512     512    0 mq-deadline      64 128    0B
└─sda3                            0    512      0     512     512    0 mq-deadline      64 128    0B
  └─ubuntu--vg-ubuntu--lv         0    512      0     512     512    0                 128 128    0B
sdb                               0    512      0     512     512    0 mq-deadline      64 128    0B
└─sdb1                            0    512      0     512     512    0 mq-deadline      64 128    0B
sdc                               0   4096      0    4096     512    1 mq-deadline       2 128    0B
└─sdc1                            0   4096      0    4096     512    1 mq-deadline       2 128    0B
sdd                               0   4096      0    4096     512    1 mq-deadline       2 128    0B
└─sdd1                            0   4096      0    4096     512    1 mq-deadline       2 128    0B
nvme1n1                           0    512    512     512     512    0 none           1023 128    0B
nvme0n1                           0    512    512     512     512    0 none           1023 128    0B

So to format with 4k LBA I ran:

sudo nvme format -l 1 /dev/nvme0n1

Now the LBA reports 4k

lido@tower:~$ sudo nvme list
Node             SN                   Model                                    Namespace Usage                      Format           FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1     21118230000128562430 Force MP600                              1           2.00  TB /   2.00  TB      4 KiB +  0 B   EGFM13.0
/dev/nvme1n1     21032520480143       PCIe SSD                                 1           2.05  TB /   2.05  TB      4 KiB +  0 B   ECFM13.3

Next is setting up partitions and filesystem.

sudo gdisk /dev/nvme0n1
Found valid GPT with protective MBR; using GPT.
Disk /dev/nvme0n1: 488378646 sectors, 1.8 TiB
Model: Force MP600
Sector size (logical/physical): 4096/4096 bytes
Disk identifier (GUID): CC8D83FE-BA47-4B57-8BED-3FD4AEC3361A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 488378640
Partitions will be aligned on 256-sector boundaries
Total free space is 250 sectors (1000.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1             256       488378640   1.8 TiB     8300  Linux filesystem

Formatting the partition as xfs.

sudo mkfs.xfs -m crc=0 /dev/nvme0n1p1 -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment