Unable to get SMART information for external drives

I am trying to get SMART information for external USB drives. I use the following query to get the disk temperature, however the query always returns one object in the collection, which is my internal hard drive.

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData"); foreach (ManagementObject queryObj in searcher.Get()) { if (queryObj["VendorSpecific"] != null) { byte[] arrVendorSpecific = (byte[])(queryObj["VendorSpecific"]); string temp = arrVendorSpecific[115].ToString(); } } 

So far I have tried 3 different disks from different suppliers, but all my attempts to get information have failed.

What am I doing wrong and how can I get SMART information for external drives via WMI?

EDIT: I tried PassMarks DiskCheckup and was able to get SMART information for all drives.

EDIT2:

Digging deeper, I found this paragraph in SmartMonTools INSTALL a file under Windows:

SCSI and USB devices are accessed via SPTI . Special driver support is not required.

Now I think that all I need to do is include this in a WMI request, can anyone help?

+6
source share
1 answer

SMART is part of the ATA standard. Even the name of the WMI class reflects this.

When you connect the device via USB, it communicates with your system using the USB mass storage protocol. It just does not support SMART. As a rule, a USB hard drive is no different from a connected USB drive or SD card, so SMART does not make sense here. The same goes for SCSI, Firewire, etc., These are different protocols. You don’t know what is sitting on the other end, this may not say ATA at all.

Some protocols, such as those used by USB hard drives, allow ATA commands to be sent across different protocol layers, as you said, SPTI is one of these methods. Although it is supported by many devices, it is a kind of hack and may not be supported by each USB drive controller or it may even cause problems (any ATA packet may be transmitted, which can be dangerous). RAID devices can use other proprietary protocols to pass through ATA commands.

Basically, there is no common protocol to speak with these devices, and although I cannot be absolutely positive, I am sure that it is simply not supported by WMI, because it is a very difficult task.

Smartmontools has a huge database of devices, disks and controllers (see drivedb.h for an understanding, it's massive), it is tested and regularly updated, as well as how it knows how to communicate with each of these devices. The low-level device of voodoo magic, basically. OSs don’t need to know all this at all, they just know how to talk to USB, Firewire, RAID devices, etc. With appropriate drivers. Crossing protocol boundaries is not what these drivers usually do.

Therefore, I suggest you use smartmontools and analyze its output, this will save you a lot of pain.

+1
source

Source: https://habr.com/ru/post/972650/


All Articles