Thursday, March 24, 2016

Linux - Update Kernel Settings for Rotational and SSDs

"/sys/block/sd[b-e]/queue/rotational" is used to stat if a device is of rotational type or non-rotational type. If it sets to 1, the kernel will see it as a rotational drive and 0 for non-rotational drive.

Since SSDs provide us a rapid increase in performances, it is important that kernel recogonizes the correct device type and react accordingly. Traditioanlly, 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, by eliminating seeks and rotational delays, care a lot less about seeks, so expanding 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.

To change the value of rotational, simply do a:
# echo 0 > /sys/block/sdb/queue/rotational

Then add to /etc/rc.local
# vi /etc/rc.local
add
echo 0 > /sys/block/sdb/queue/rotational

No comments: