Opened 4 years ago

Closed 3 years ago

#1381 closed enhancement (fixed)

--nocheck standby is ignored if device does not support power check which causes spin up

Reported by: Marc Gutt Owned by: Christian Franke
Priority: minor Milestone: Release 7.3
Component: smartctl Version: 7.1
Keywords: Cc:

Description

I connected an HDD through USB. The USB controller blocks some hdparm/ATA commands and by that the following:

smartctl -n standby -A /dev/sdg

returns:

CHECK POWER MODE: incomplete response, ATA output registers missing
CHECK POWER MODE not implemented, ignoring -n option

I would prefer that it does not ignore the -n option in such a case to avoid HDD spin up (the reason why -n was used).

This caused a small bug in Unraid:
https://forums.unraid.net/bug-reports/stable-releases/683-usb-hdds-randomly-spin-up-but-status-stays-unchanged-r1091/

But I was able to solve it by changing the command to the "-i" option:

smartctl -n standby -i /dev/sdg

It returns the same "not implemented" error, but it does luckily not spin up the HDD.

Change History (6)

comment:1 by Christian Franke, 4 years ago

Component: allsmartctl
Milestone: undecided

Long standing (14+ year old, see r2227) behavior should not be changed as others may rely on it.

We could possibly further enhance the option as
-n POWERMODE[,STATUS1[,STATUS2]].
If STATUS2 is specified and CHECK POWER MODE is not supported, exit immediately with this status.

For example:

  smartctl -n standby,3,5 -x /dev/ice

If device is in STANDBY mode, exit(3). If CHECK POWER MODE is not supported, exit(5). Otherwise proceed as usual.

PS: It depends on drive firmware, USB bridge and OS whether specific pass-through commands spin up the disk. smartctl -i may also spin up and smartctl -A may not.

comment:2 by Marc Gutt, 4 years ago

I would prefer:
-n standby
-n standby-force

"force" adds the new "exit(5)" behaviour and would be the short form of "force nocheck even device does not support power check mode". Or "standby-skip" as a short form of "skip on errors".

comment:3 by Christian Franke, 3 years ago

Milestone: undecidedRelease 7.3

comment:4 by Simon Fairweather, 3 years ago

Can I suggest the following solution

Use smartctl -n standby,- this will pass a negative value of the existing options i.e. -2 for standby.

Example

root@unraid:~# smartctl -n standby,2 /dev/sdb
smartctl 7.2 2020-12-15 r5131 [x86_64-linux-5.10.1-Unraid] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

CHECK POWER MODE: incomplete response, ATA output registers missing
CHECK POWER MODE not implemented, ignoring -n option
ATA device successfully opened

Use 'smartctl -a' (or '-x') to print SMART (and more) information

Proposed solution would return the following.

root@unraid:~# smartctl -n standby,- /dev/sdb
smartctl 7.2 2020-12-15 r5131 [x86_64-linux-4.19.107-Unraid] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

Device is in STANDBY mode, exit(2)

A value could be specified after the - to change the return value i.e. standby,-5 would result in exit(5)

if you think this is a viable solution I will look to create a patch?

comment:5 by Christian Franke, 3 years ago

Owner: set to Christian Franke
Status: newaccepted

Thanks. Not needed for ATA because I will soon commit code for the -n POWERMODE[,STATUS1[,STATUS2]] extension described above. This variant is IMO more flexible because it allows to specify a different exit status for each case (including 0 to interpret one or both cases as success).

Feel free to provide a related patch for SCSI later.

comment:6 by Christian Franke, 3 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.