Linux: how to check if the disk is SSD or not

root's picture

With SSD arriving more and more in our lives it is natural to find it on linux servers too.
Not working with SSD in this area much, haven't found much interest of finding ssd related things in Linux so far.

So, nowadays one can wonder wondering: how would I know if my disks in Linux are SSD or not?
A valid response would be: close the system, open it up and see what disk you have there :)))

But what if this is a linux server far far away? You need to be able to find out these things from OS level.

So, without too much bla bla (I like to bla bla sometimes), it is fairly simple to find out this.
I have this virtual machine running in a nice mac mini with ESXI on it and one datastore is SSD. I have 3 disks in this machine and one is SSD: /dev/sdb.

18:06:12 root@eeny:~# fdisk -l /dev/sd? | grep "^Disk /"
Disk /dev/sda: 1 TiB, 1099511627776 bytes, 2147483648 sectors
Disk /dev/sdb: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk /dev/sdc: 3.64 TiB, 4000787029504 bytes, 7814037167 sectors

There is in /sys a place, /sys/block/sd?/queue/rotational, where if you get 0 is SSD and 1 is normal disk. Rotational means disk that spins :)

So as it is clearly stated below, /dev/sdb is SSD! Hooray :)

18:06:16 root@eeny:~# cat /sys/block/sda/queue/rotational
18:06:52 root@eeny:~# cat /sys/block/sdb/queue/rotational
18:06:55 root@eeny:~# cat /sys/block/sdc/queue/rotational

Want more?

There is also a way to achieve this result with lsblk command:

Again, sdb = 0 which means SSD.

18:12:20 root@eeny:~# lsblk -d -o name,rota
sda     1
sdb     0
sdc     1
sr0     1

Still not satisfied?!! OK...
You can get this also with smartmontools :P
Again, sdb is SSD. Incredible!
HINT: virtual disks do not show usually rotational state if the disk is not SSD. So, /dev/sda and /dev/sdb are virtual disks but because /dev/sdb is marked by the host as SSD, it contains this value.

18:12:22 root@eeny:~# smartctl -a /dev/sda | grep 'Rotation Rate'
18:14:18 root@eeny:~# smartctl -a /dev/sdb | grep 'Rotation Rate'
Rotation Rate:        Solid State Device
18:14:22 root@eeny:~# smartctl -a /dev/sdc | grep 'Rotation Rate'
Rotation Rate:    5980 rpm

Ok, I am done. If you are not satisfied there is nothing else I can do here...

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.