我正在寻找识别磁盘是SSD还是HDD的方法?我发现有一种方法可以检测到它.这是通过读取cat / sys / block / sda / queue / rotation的值?如果它是1那么它是HDD,否则它是SSD.我想知道这个文件是什么/ sys / block / sda / queue / rotate?为什么它被内核使用?这个由内核维护的k对象是什么?
来自:
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.
另见: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.