linux-nvme / nvme-cli

NVMe management command line interface.
https://nvmexpress.org
GNU General Public License v2.0
1.47k stars 656 forks source link

nvme format failing for Hynix pc601 #816

Closed way2me closed 2 years ago

way2me commented 4 years ago

Please help me to troubleshoot this problem.

Command Output:-

ubuntu@ubuntu:/$ sudo nvme format /dev/nvme0 --lbaf=1
Invalid namespace ID, specify a namespace to format or use '-n 0xffffffff' to format all namespaces on this controller.

ubuntu@ubuntu:/$ sudo nvme format /dev/nvme0 --lbaf=1 -n 1
NVMe status: INVALID_FORMAT: The LBA Format specified is not supported. This may be due to various conditions(0x10a)
ubuntu@ubuntu:/$ sudo nvme id-ns /dev/nvme0n1
NVME Identify Namespace 1:
nsze    : 0x3b9e12b0
ncap    : 0x3b9e12b0
nuse    : 0x3b9e12b0
nsfeat  : 0
nlbaf   : 1
flbas   : 0
mc      : 0
dpc     : 0
dps     : 0
nmic    : 0
rescap  : 0
fpi     : 0
dlfeat  : 0
nawun   : 0
nawupf  : 0
nacwu   : 0
nabsn   : 0
nabo    : 0
nabspf  : 0
noiob   : 0
nvmcap  : 0
nsattr  : 0
nvmsetid: 0
anagrpid: 0
endgid  : 0
nguid   : ace42e000a13c0112ee4ac0000000001
eui64   : ace42e000a13c011
lbaf  0 : ms:0   lbads:9  rp:0 (in use)
lbaf  1 : ms:0   lbads:12 rp:0 
ubuntu@ubuntu:~$ sudo smartctl -a /dev/nvme0
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-42-generic] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       SKHynix_HFS512GD9TNG-L5B0B
Serial Number:                      XXXXXXXXXXXX
Firmware Version:                   80750C10
PCI Vendor/Subsystem ID:            0x1c5c
IEEE OUI Identifier:                0xace42e
Controller ID:                      1
Number of Namespaces:               1
Namespace 1 Size/Capacity:          512,110,190,592 [512 GB]
Namespace 1 Formatted LBA Size:     512
Namespace 1 IEEE EUI-64:            ace42e 000a13c011
Local Time is:                      Sat Oct  3 11:14:57 2020 UTC
Firmware Updates (0x16):            3 Slots, no Reset required
Optional Admin Commands (0x0017):   Security Format Frmw_DL Self_Test
Optional NVM Commands (0x005e):     Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
Maximum Data Transfer Size:         64 Pages
Warning  Comp. Temp. Threshold:     86 Celsius
Critical Comp. Temp. Threshold:     87 Celsius

Supported Power States
St Op     Max   Active     Idle   RL RT WL WT  Ent_Lat  Ex_Lat
 0 +   6.3000W       -        -    0  0  0  0        5       5
 1 +   2.4000W       -        -    1  1  1  1       30      30
 2 +   1.9000W       -        -    2  2  2  2      100     100
 3 -   0.0500W       -        -    3  3  3  3     1000    1000
 4 -   0.0040W       -        -    3  3  3  3     1000    9000

Supported LBA Sizes (NSID 0x1)
Id Fmt  Data  Metadt  Rel_Perf
 0 +     512       0         0
 1 -    4096       0         0

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02)
Critical Warning:                   0x00
Temperature:                        49 Celsius
Available Spare:                    100%
Available Spare Threshold:          10%
Percentage Used:                    0%
Data Units Read:                    2,842,547 [1.45 TB]
Data Units Written:                 1,701,565 [871 GB]
Host Read Commands:                 11,828,131
Host Write Commands:                6,840,613
Controller Busy Time:               124
Power Cycles:                       221
Power On Hours:                     70
Unsafe Shutdowns:                   155
Media and Data Integrity Errors:    0
Error Information Log Entries:      0
Warning  Comp. Temperature Time:    0
Critical Comp. Temperature Time:    0
Temperature Sensor 1:               49 Celsius
Temperature Sensor 2:               52 Celsius

Error Information (NVMe Log 0x01, max 256 entries)
No Errors Logged

Thanks

keithbusch commented 4 years ago

Do you only have one nvme device? If not, make sure nvme0 really is the parent controller to nvme0n1. Sometimes it's not. So if you have more than one nvme, try to use the nvme0n1 handle consistently rather than sometimes using nvme0.

If you have only one, or are sure nvme0 is the parent to nvme0n1, then the 2nd format command looks fine. Does it work if you use lbaf 0?

If not, try using namespace id 0xffffffff. Some controllers just don't allow formatting a specific namespace, even if they only have one. The 'id-ctrl' fna field should indicate if this is one of those types, though that's not the right return code even if this is one of those kinds of controllers.

way2me commented 4 years ago

I have only 1 drive in this laptop. With 0xffffffff, same output with lbaf=0 too, result is same, failed with same output

ubuntu@ubuntu:~$ sudo nvme format /dev/nvme0 -n 0xffffffff -l 1
NVMe status: INVALID_FORMAT: The LBA Format specified is not supported. This may be due to various conditions(0x10a)
ubuntu@ubuntu:~$ sudo nvme id-ctrl -H /dev/nvme0n1
NVME Identify Controller:
vid       : 0x1c5c
ssvid     : 0x1c5c
sn        : XXXXXXXXXXXXX   
mn        : SKHynix_HFS512GD9TNG-L5B0B              
fr        : 80750C10
rab       : 4
ieee      : ace42e
cmic      : 0
  [3:3] : 0 ANA not supported
  [2:2] : 0 PCI
  [1:1] : 0 Single Controller
  [0:0] : 0 Single Port

mdts      : 6
cntlid    : 0x1
ver       : 0x10300
rtd3r     : 0x7a120
rtd3e     : 0x1e8480
oaes      : 0x200
[14:14] : 0 Endurance Group Event Aggregate Log Page Change Notice Not Supported
[13:13] : 0 LBA Status Information Notices Not Supported
[12:12] : 0 Predictable Latency Event Aggregate Log Change Notices Not Supported
[11:11] : 0 Asymmetric Namespace Access Change Notices Not Supported
  [9:9] : 0x1   Firmware Activation Notices Supported
  [8:8] : 0 Namespace Attribute Changed Event Not Supported

ctratt    : 0
  [9:9] : 0 UUID List Not Supported
  [7:7] : 0 Namespace Granularity Not Supported
  [5:5] : 0 Predictable Latency Mode Not Supported
  [4:4] : 0 Endurance Groups Not Supported
  [3:3] : 0 Read Recovery Levels Not Supported
  [2:2] : 0 NVM Sets Not Supported
  [1:1] : 0 Non-Operational Power State Permissive Not Supported
  [0:0] : 0 128-bit Host Identifier Not Supported

rrls      : 0
crdt1     : 0
crdt2     : 0
crdt3     : 0
oacs      : 0x17
  [9:9] : 0 Get LBA Status Capability Not Supported
  [8:8] : 0 Doorbell Buffer Config Not Supported
  [7:7] : 0 Virtualization Management Not Supported
  [6:6] : 0 NVMe-MI Send and Receive Not Supported
  [5:5] : 0 Directives Not Supported
  [4:4] : 0x1   Device Self-test Supported
  [3:3] : 0 NS Management and Attachment Not Supported
  [2:2] : 0x1   FW Commit and Download Supported
  [1:1] : 0x1   Format NVM Supported
  [0:0] : 0x1   Security Send and Receive Supported

acl       : 3
aerl      : 7
frmw      : 0x16
  [4:4] : 0x1   Firmware Activate Without Reset Supported
  [3:1] : 0x3   Number of Firmware Slots
  [0:0] : 0 Firmware Slot 1 Read/Write

lpa       : 0x2
  [3:3] : 0 Telemetry host/controller initiated log page Not Supported
  [2:2] : 0 Extended data for Get Log Page Not Supported
  [1:1] : 0x1   Command Effects Log Page Supported
  [0:0] : 0 SMART/Health Log Page per NS Not Supported

elpe      : 255
npss      : 4
avscc     : 0x1
  [0:0] : 0x1   Admin Vendor Specific Commands uses NVMe Format

apsta     : 0x1
  [0:0] : 0x1   Autonomous Power State Transitions Supported

wctemp    : 359
cctemp    : 360
mtfa      : 0
hmpre     : 0
hmmin     : 0
tnvmcap   : 0
unvmcap   : 0
rpmbs     : 0
 [31:24]: 0 Access Size
 [23:16]: 0 Total Size
  [5:3] : 0 Authentication Method
  [2:0] : 0 Number of RPMB Units

edstt     : 60
dsto      : 1
fwug      : 0
kas       : 0
hctma     : 0x1
  [0:0] : 0x1   Host Controlled Thermal Management Supported

mntmt     : 273
mxtmt     : 358
sanicap   : 0x3
  [31:30] : 0   Additional media modification after sanitize operation completes successfully is not defined
  [29:29] : 0   No-Deallocate After Sanitize bit in Sanitize command Supported
    [2:2] : 0   Overwrite Sanitize Operation Not Supported
    [1:1] : 0x1 Block Erase Sanitize Operation Supported
    [0:0] : 0x1 Crypto Erase Sanitize Operation Supported

hmminds   : 0
hmmaxd    : 0
nsetidmax : 0
anatt     : 0
anacap    : 0
  [7:7] : 0 Non-zero group ID Not Supported
  [6:6] : 0 Group ID does not change
  [4:4] : 0 ANA Change state Not Supported
  [3:3] : 0 ANA Persistent Loss state Not Supported
  [2:2] : 0 ANA Inaccessible state Not Supported
  [1:1] : 0 ANA Non-optimized state Not Supported
  [0:0] : 0 ANA Optimized state Not Supported

anagrpmax : 0
nanagrpid : 0
sqes      : 0x66
  [7:4] : 0x6   Max SQ Entry Size (64)
  [3:0] : 0x6   Min SQ Entry Size (64)

cqes      : 0x44
  [7:4] : 0x4   Max CQ Entry Size (16)
  [3:0] : 0x4   Min CQ Entry Size (16)

maxcmd    : 0
nn        : 1
oncs      : 0x5e
  [7:7] : 0 Verify Not Supported
  [6:6] : 0x1   Timestamp Supported
  [5:5] : 0 Reservations Not Supported
  [4:4] : 0x1   Save and Select Supported
  [3:3] : 0x1   Write Zeroes Supported
  [2:2] : 0x1   Data Set Management Supported
  [1:1] : 0x1   Write Uncorrectable Supported
  [0:0] : 0 Compare Not Supported

fuses     : 0
  [0:0] : 0 Fused Compare and Write Not Supported

fna       : 0x6
  [2:2] : 0x1   Crypto Erase Supported as part of Secure Erase
  [1:1] : 0x1   Crypto Erase Applies to All Namespace(s)
  [0:0] : 0 Format Applies to Single Namespace(s)

vwc       : 0x1
  [0:0] : 0x1   Volatile Write Cache Present

awun      : 0
awupf     : 0
nvscc     : 1
  [0:0] : 0x1   NVM Vendor Specific Commands uses NVMe Format

nwpc      : 0
  [2:2] : 0 Permanent Write Protect Not Supported
  [1:1] : 0 Write Protect Until Power Supply Not Supported
  [0:0] : 0 No Write Protect and Write Protect Namespace Not Supported

acwu      : 0
sgls      : 0
 [1:0]  : 0 Scatter-Gather Lists Not Supported

mnan      : 0
subnqn    : 
ioccsz    : 0
iorcsz    : 0
icdoff    : 0
ctrattr   : 0
  [0:0] : 0 Dynamic Controller Model

msdbd     : 0
ps    0 : mp:6.3000W operational enlat:5 exlat:5 rrt:0 rrl:0
          rwt:0 rwl:0 idle_power:- active_power:-
ps    1 : mp:2.4000W operational enlat:30 exlat:30 rrt:1 rrl:1
          rwt:1 rwl:1 idle_power:- active_power:-
ps    2 : mp:1.9000W operational enlat:100 exlat:100 rrt:2 rrl:2
          rwt:2 rwl:2 idle_power:- active_power:-
ps    3 : mp:0.0500W non-operational enlat:1000 exlat:1000 rrt:3 rrl:3
          rwt:3 rwl:3 idle_power:- active_power:-
ps    4 : mp:0.0040W non-operational enlat:1000 exlat:9000 rrt:3 rrl:3
          rwt:3 rwl:3 idle_power:- active_power:-
way2me commented 4 years ago
fna       : 0x6
  [2:2] : 0x1   Crypto Erase Supported as part of Secure Erase
  [1:1] : 0x1   Crypto Erase Applies to All Namespace(s)
  [0:0] : 0 Format Applies to Single Namespace(s)
keithbusch commented 4 years ago

I think you'd have to open a bug with your vendor at this point.

way2me commented 4 years ago

Any other way to change sector size?

keithbusch commented 4 years ago

No other spec defined way. Your drive is simply not behaving to the spec, so I'd guess it's a drive firmware bug. You'll need to contact the vendor for a solution.

tim-oleksii commented 4 years ago

@way2ezee is it pc401 drive?

keithbusch commented 4 years ago

@way2ezee is it pc401 drive?

It may appear so based on the model number, though I am not sure what the L5B0B suffix indicates. That actually looks closer aligned to the PC601 from what I can gather from the public listings on skhynix.com.

tim-oleksii commented 4 years ago

Seems like pc601 judging by sn. I'd try to contact Lenovo & hynix simultaneously.

way2me commented 4 years ago

Yep, pc601

tim-oleksii commented 4 years ago

@way2ezee Sorry, my comment may look misleading - please e-mail them. As it's PC601, it might get fixed.

way2me commented 4 years ago

They do not take customers seriously https://forums.lenovo.com/t5/ThinkPad-T400-T500-and-newer-T-series-Laptops/nvme-format-failing-with-4096-sector-size/m-p/5043069?page=1#5160285

keithbusch commented 4 years ago

Don't take it personally. Your experience so far is par for the course with any vendor.

keithbusch commented 4 years ago

BTW, they seem to think it could be a security setting on the device. That could certainly prevent a format command, but I don't think they're using the correct error code. Security sequences should use the "Command Sequence Error".

On a side note, while the 4k format provides all the right guarantees for more optimal access granularity, as long as you partition your device on a 4k boundary, most Linux filesystems will use 4k aligned access too.

tomty89 commented 3 years ago

I got error performing sanitize or format:

[tom@ideapad ~]$ sudo nvme sanitize /dev/nvme0n1 -a 2
NVMe status: ACCESS_DENIED: Access to the namespace and/or LBA range is denied due to lack of access rights(0x4286)
[tom@ideapad ~]$ sudo nvme format /dev/nvme0 -n 1 -l 1
You are about to format nvme0, namespace 0x1.
Controller nvme0 has child namespace(s):nvme0n1

WARNING: Format may irrevocably delete this device's data.
You have 10 seconds to press Ctrl-C to cancel this operation.

Use the force [--force|-f] option to suppress this warning.
Sending format operation ... 
NVMe status: INVALID_FORMAT: The LBA Format specified is not supported. This may be due to various conditions(0x410a)

And the suspend trick worked for me on my IdeaPad S540-13ARE / WD SN 730: https://superuser.com/questions/1574424/format-ssd-with-nvme-lba-format-specified-is-not-supported

Looks like some UEFI firmwares implement some sort of freeze for NVMe drives like they did for ATA drives...I recall the same trick can help on some machine if one wants to perform ATA Secure Erase on an internally attached SATA SSD...

TheLQ commented 2 years ago

Thank you @tomty89 can confirm that silly workaround worked

# nvme id-ns /dev/nvme0 --namespace-id=1 -H
LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0 Best (in use)
LBA Format  1 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0 Best

# nvme format /dev/nvme0n1 --lbaf=1
You are about to format nvme0n1, namespace 0x1.
Namespace nvme0n1 has parent controller(s):nvme0
...
Sending format operation ...
NVMe status: INVALID_FORMAT: The LBA Format specified is not supported. This may be due to various conditions(0x10a)

# systemctl suspend
...physically wake machine....

# nvme format /dev/nvme0 --lbaf=1
You are about to format nvme0, namespace 0xffffffff(ALL namespaces).
Controller nvme0 has child namespace(s):nvme0n1
Sending format operation ...
Success formatting namespace:ffffffff
failed to re-read partition table

My setup in case it helps

sn        : ADA8N658110108P6M
mn        : SHGP31-2000GM
igaw commented 2 years ago

Doesn't seem there is anything we can do here. Closing the issue, if you think is still relevant please reopen.

ku1ik commented 1 year ago

Had the same problem with WD SN700, the suspend trick worked for me :+1:

aggieNick02 commented 4 months ago

The suspend/resume trick has worked for me as well on a number of motherboards, but not all. So YMMV, depending on the motherboard.

aggieNick02 commented 4 months ago

Please see my comment on this related issue here. It covers what is happening, why the suspend/resume trick often works, and what you can do when it does not.