How to determine storage type (SSD drive or HHD .mechanical drive), using C language

Shaobo Wang picture Shaobo Wang · Nov 11, 2009 · Viewed 7.8k times · Source

How can I, from a C program, read the hardware information of a drive? (I.e. to determine if the drive is an SSD or a mechanical disk.)

Answer

pan1nx picture pan1nx · Jan 9, 2010

SSD are supposed to identify themselves as non-rotative. For linux, as example, you can get the info via sysfs:

cat /sys/block/sda/queue/rotational

If it returns 0, you have SSD...