Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the significance of /queue/rotational in Linux?

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?

like image 319
dexterous Avatar asked Dec 04 '13 10:12

dexterous


1 Answers

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.

like image 145
Jon Lin Avatar answered Nov 05 '22 06:11

Jon Lin