Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to find if disk is SSD or HDD

📅 2016-Sep-28 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ hdd, ssd, sys ⬩ 📚 Archive

Disk IO can be the bottleneck for certain programs. When I work with such programs on remote servers, I prefer to place their data or direct their output to SSD instead of HDD. I can view the available partitions and their filesystems using the df command. But, how to find out which of the mounted partitions is on a SSD and which on hard disk?

You probably know that the disk of a partition listed as /dev/sdb7 is /dev/sdb. That is, by removing the numerical suffix from the partition, you get the disk.

To find out if the disk is SSD or HDD, check the /sys pseudo filesystem using the disk name:

$ cat /sys/block/sdb/queue/rotational

If it is HDD, and thus a rotational disk, the value will be 1. For SSD, the value will be 0.

Tried with: Ubuntu 14.04