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 :)
[/i]NOTE: if the ssd device is connected via USB, sometimes this method will not see it ass "not rotational".[/i]

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

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
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

With lshw command

There is another way to check if you have ssd or not, if the disk is not virtual (e.g. provided by vmware or virtualbox or etc.).
The command lshw will scan for all disks and display their information including name hardware path. This is useful information.

15:26:18 root@minivm:~# lshw -short -C disk
H/W path                     Device      Class       Description
================================================================
/0/100/11/3/0.0.0            /dev/cdrom  disk        VMware SATA CD00
/0/100/15/0/0.0.0            /dev/sda    disk        32GB Virtual disk
/0/100/15/0/0.1.0            /dev/sdb    disk        1099GB Virtual disk
/0/100/15.2/0/1/1/0.0.0      /dev/sdc    disk        120GB SA400S37120G
/0/100/15.2/0/1/2/0.0.0      /dev/sdd    disk        120GB 650
/0/100/15.2/0/1/3/0.0.0      /dev/sdf    disk        4TB 2135
/0/100/15.2/0/1/4/1/0.0.0    /dev/sdg    disk        4TB 2135
/0/100/15.2/0/1/4/2/0.0.0    /dev/sdh    disk        4TB 2135
/0/100/15.2/0/1/4/3/0.0.0    /dev/sdi    disk        4TB 2135

Also lsscsi command can show you similar information like lshw:

15:29:54 root@minivm:~# lsscsi 
[0:0:0:0]    disk    VMware   Virtual disk     2.0   /dev/sda 
[0:0:1:0]    disk    VMware   Virtual disk     2.0   /dev/sdb 
[3:0:0:0]    cd/dvd  NECVMWar VMware SATA CD00 1.00  /dev/sr0 
[63:0:0:0]   disk    KINGSTON  SA400S37120G    8101  /dev/sdc 
[64:0:0:0]   disk    ADATA SU 650              XD0R  /dev/sdd 
[65:0:0:0]   disk    ASMT     2135             0     /dev/sdf 
[66:0:0:0]   disk    ASMT     2135             0     /dev/sdg 
[67:0:0:0]   disk    ASMT     2135             0     /dev/sdh 
[68:0:0:0]   disk    ASMT     2135             0     /dev/sdi

All this info can be shown only if the method used for connecting the disk is made to do so.
As example, some USB racks do not have the capability to send to the OS the disk information so they will be shown with nothing or with the rack's information (e.g. ASMT 2135 is not the disk info but the rack to which the disk is connected).

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.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root