How to check if external hard drive is spinning or in sleep mode through the command line?

How can I determine through the command line whether or not an external drive that is connected to my system is awake (spinning) or sleeping?

None of the answers here have helped. The Powershell method doesn't work at all, and the smartctl method is described below. I also haven't tried the hdparm method because I'm trying this on Windows and according to numerous posts online the command hdparm -C will wakeup the drive anyway.

Testing an external Seagate drive.

Command used:

smartctl -n standby G:

The above works only when the drive is awake, and it instantly reports:

Device is in ACTIVE or IDLE mode

However if the drive is sleeping, the command hangs for 1-2 minutes and then it reports:

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

You could say that the different error message solves this question but I'm hoping to find a clean solution where I won't have to wait for a couple of minutes to get an incomplete response. This is going to be used in a script that probes all connected disks. Also it doesn't always work like that, see below.

Testing an external WD drive.

The above command shows the same message either if the drive is spinning or not:

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

However it doesn't hang like before and the response is instant.

Testing an internal WD drive.

When the drive is spinning:

Device is in ACTIVE or IDLE mode

When the drive is sleeping:

Device is in STANDBY (OS) mode, exit(2)

This is the only case where it works as expected.


Solution 1:

You can’t do this unless the external drive’s bridge board somehow conveys that information.

All of the Windows commands you refer to are related to drives that are directly connected to a system’s motherboard. When a drive is connected directly to the system’s motherboard, the extra data connections are what allow those commands to work.

In the case of an external drive, the drive is connected to your system via a bridge board. The board basically manages taking USB commands and translating them to commands the core hard drive’s interface uses: Whether it be SATA, PATA, IDE, etc…

In the most common type of external drive setup — and you mention “external Seagate drive” — a SATA drive connects to a bridge board which allows for a USB connection to the drive. That USB connection is mainly there to read and write data; not convey other data such as SMART data or data related to drive sleep/wake state.

As this macOS-specific blog post from Other World Computing states:

“In addition, external and USB drives are usually not SMART-enabled.”

The post might be macOS specific, but the general concept is the same: External drives are usually not SMART-enabled.

The only way you could get that extra data sent back through and external connection is if the bridge board somehow conveys that data. Or if the connection is something like eSATA connection which is honestly an oddball external connection.

I’m not too sure if old school SCSI devices could send such data bace externally as well as internally, but if I recall correctly, there’s very little difference between SCSI internal versus external protocols so possibly system level commands that would convey deeper data for internal SCSO drives could be used for external SCSI drives as well.

But that is all academic nowadays in a world where the most typical connection between an external drive to a system is a USB connection of some kind.

PS: In some cases, a manufacturer will provide some kind of proprietary software that would allow your main system OS to connect directly to the bridge board in an external device. This is typically used for flashing the firmware on the bridge board but might convey deeper disk data such as SMART status. But that is a big “might”; the proprietary software only connects to the external drive in the way the manufacturer wants it to. And will only convey the data the manufacturer wants to provide. And will most likely not convey any deeper data in a way common internal hard drive commands would need them.

Solution 2:

After reading the manpage I found by accident the -d option which lets you specify "the type of device". So the following command seems to work as expected:

smartctl -d ata -n standby G:

When the drive is sleeping, I get an instant reponse:

Device is in STANDBY (OS) mode, exit(2).

When the drive is spinning I also get an instant responde:

Device is in ACTIVE or IDLE mode.

I'm not sure why -d ata works but -d sat doesn't, though.

The command has to be run in an elevated prompt on Windows, otherwise it will give false results for some disks: for example my internal WD drive is always being reported as ACTIVE if the command is issued on a non-elevated prompt.