How to detect SSD drive?

Is there any way to tell if a volume you are about to write to is an SSD drive versus a hard drive?
I would like to place this information in a field. I couldn’t find anything within MBS or on this forum, but happy to be proven wrong.

which platform ?

also things can mask the underlying storage technologies especially when using servers or shared storage. Or if the host is a virtual machine.

I would prefer cross-platform, but will accept Windows and/or macOS

Running this in a powershell on windows will return you the information you need which is the SpindleSpeed, if its 0 then its a non-spinning disk and MediaType is 4 if its an SSD.

Get-WmiObject -Namespace "root/Microsoft/Windows/Storage" -Class MSFT_PhysicalDisk

If you have MBS then you could use WMIObjectMBS to get this information without dropping into a shell.

These are the physical disks, you would then need to translate that to a volume on said disk which could be calculated using data from:

Get-WmiObject -Namespace "root/Microsoft/Windows/Storage" -Class MSFT_Volume

Edit: Windows 8 and above only.

on the mac, execute a system shell with system_profiler SPSerialATADataType
then search for “Media Type” on the result you have “Solid State” for an ssd.

[quote=372055:@Jean-Yves Pochez]on the mac, execute a system shell with system_profiler SPSerialATADataType
then search for “Media Type” on the result you have “Solid State” for an ssd.[/quote]
No result on a Late 2016 MacBook Pro :frowning:
It’s SSD is listed here: system_profiler SPNVMeDataType

what about querying diskutil info disk0 and search for “Solid State: Yes/No”? Maybe that would at least work and not depend on the “connector type”.

But how to connect the “Volume” with the Drive…?
The Volume you’re going to write to could be a DiskImage. What then? That DiskImage can be on either HDD, SSD - or it’s just some virtual machine/volume. I doubt you can query all the way back to it’s Host.
Oh, and what if it is a “Fusion Drive”?

Thank you for the possibilities, I check them out.

HI David,

Windows relies on the supplier to add the string HDD or SDD to the hardware. Here is a method which is OK, and it may show a false positive for a RAID system.

Call the following in a shell:

wmic path Win32_PerfRawData_PerfDisk_PhysicalDisk get diskreadbytespersec

My value on the SSD was 4,948,607,744 bytes per second (4.9 GB/Sec). A snippet from the article is shown below, and in 2012 (when the article was written) the SSD’s were between 11 MB/Sec and 130 MB/Sec and none of the HDD could approach 8 MB/sec.

[quote]Will disk defragmentation be disabled by default on SSDs?

Yes. The automatic scheduling of defragmentation will exclude partitions on devices that declare themselves as SSDs. Additionally, if the system disk has random read performance characteristics above the threshold of 8 MB/sec, then it too will be excluded. The threshold was determined by internal analysis.

The random read threshold test was added to the final product to address the fact that few SSDs on the market today properly identify themselves as SSDs. 8 MB/sec is a relatively conservative rate. While none of our tested HDDs could approach 8 MB/sec, all of our tested SSDs exceeded that threshold. SSD performance ranged between 11 MB/sec and 130 MB/sec. Of the 182 HDDs tested, only 6 configurations managed to exceed 2 MB/sec on our random read test. The other 176 ranged between 0.8 MB/sec and 1.6 MB/sec.[/quote]

Here is a link to the article:
Article 9 Feb 2012

Another Article 15 June 2017 has HDD’s at ~120 MB/second and SDD’s at >500 MB/Second.

Edit: Sorry, my mistake. DiskReadBytesPerSec is in bytes per sector, not bytes per second. Use:

wmic path Win32_PerfRawData_PerfDisk_PhysicalDisk get avgdiskbytesperread

We did for an app with System profiler, but there are a few possible values.

Here some code I used in an app.
MyShellSSD is shell subclass:

shSSD = new MyShellSSD shSSD.mode = 1 shSSD.Execute "system_profiler SPStorageDataType"

and in MyShellSSD.Completed event, we do have:

[code]Sub Completed() Handles Completed
dim retest as Boolean
dim s as string = me.Result
dim HasRotational as integer = 0
dim HasSSD as integer = 0

if s.Encoding = nil then
s = DefineEncoding(s, encodings.UTF8)
end if

s = ReplaceLineEndings(s, EndOfLine)
dim lines() as string = split(s,EndOfLine)

dim u as integer = UBound(lines)

for i as integer = 0 to u
dim line as string = trim(lines(i))

if line = "Mount Point: /" then
  // found Mount Point:
  
  for j as integer = i+1 to u
    line = trim(lines(j))
    
    if line = "" then 
      // next disk
      exit
    end if
    
    if line = "Physical Volumes:" or line = "Physical Drive:" then
      // found Physical Volumes:
      
      for k as integer = j+1 to u
        line = trim(lines(k))
        
        if line = "" then
          // next disk
          exit
        end if
        
        if line.left(12) = "Medium Type:" then
          // found Medium Type:
          
          if instr(line,"SSD") > 0 then
            HasSSD = 1
          end if
          
          if instr(line,"Rotational") > 0 then
            HasRotational = 1
          end if
        end if
      next
      
      exit
    end if
  next
  
  exit
end if

next

if HasSSD = 1 and HasRotational = 1 then
HasSSD = -1 // fusion
end if
End Sub[/code]