There are different types of disk drives available among which most used are Hard drive (HDD) and Solid State Drive (SSD). Starting from the Kernel version 2.6.29, SSD is automatically detected by Linux systems.
This tutorial shows how to check the installed disk is SSD or HDD in a Linux system.
Method 1: Using lsblk command
Identification of the disk type can be done by using the disks with the rotational feature. lsblk command can be used to list all the connected disks and their respective rotational values as:
lsblk -d -o name,rota
NAME ROTA sda 1 sdb 1 sr0 1
The output of the above command is '1' for the ROTA which shows that the disk is HDD. In the case of SSD, the value of ROTA will be '0'.
Method 2: Check Rotational
Looking at the value of /sys/block/sdX/queue/rotational, the type of the disk can be identified where sdX is the drive name. If the value is 1 then you are using HDD while the value 0 indicates the type of disk as SSD. Run the following command to get the rotational value of the disk. In this example, sda is used to identify the disk type, you can use any drive's name available in your system.
The output '1' indicates the type of disk is HDD, for the SSD the value will be '0'
Method 3: Using smartctl
The disk type used in the Linux system can also be identified using the command-line utility tool smartctl. smartctl is part of the package smartmontools. Smartmontools is available in all Linux distributions including Ubuntu, Fedora, Centos, and RHEL.
Use the following command to install smartmontools in Linux:
sudo apt install smartmontools
To start the service, run the command:
sudo /etc/init.d/smartmontools start
CentOS and RHEL
sudo yum install smartmontools
sudo dnf install smartmontools
Smartd service will be started automatically after the installation. If not, use the following command to start the service:
udo systemctl start smartd
After installing the smartmontools package, use the following command to find if the disk is HDD or SSD.
$ sudo smartctl -a /dev/sda | grep 'Rotation Rate'
Where, /dev/sda is the name of the drive.
If the disk is HDD, the output will be as:
Rotation Rate: 5400 rpm
If the disk is SSD, output will look like:
Rotation Rate: Solid State Device
In this tutorial, we have learned how to check the disk is SSD/HDD in the Linux system.