I was searching to identify the way to detect whether a disk is SSD or HDD? I found that there is a way to detect it. This is by reading the value of cat /sys/block/sda/queue/rotational? If it is 1 then it is HDD otherwise it is SSD. I was wondering what is this file /sys/block/sda/queue/rotational? Why is it used by kernel? What is this k-object that is maintained by kernel?
From: https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
rotational (RW)
This file is used to stat if the device is of rotational type or non-rotational type.
See also: http://lwn.net/Articles/408428/
Traditionally, the block layer has been driven by the need to avoid head seeks; the use of quite a bit of CPU time could be justified if it managed to avoid a single seek. SSDs - at least the good ones - care a lot less about seeks, so expending a bunch of CPU time to avoid them no longer makes sense. There are various ways of detecting SSDs in the hardware, but they don't always work, especially with the lower-quality devices. So the block layer exports a flag under
/sys/block/<device>/queue/rotational
which can be used to override the system's notion of what kind of storage device it is dealing with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With