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.
In this tutorial, we learn how to check whether the installed disk type is SSD in a Linux system.
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. The fifth column with name "RO" shows the disk type. The column value 0 indicates SSD and 1 indicates HDD.
lsblk
The output of the above command is '0' for the RO which shows that the disk is SSD. In the case of HDD, it would have shown '1'.
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.
cat /sys/block/sda/queue/rotational
The output '1' indicates the type of disk is HDD, for the SSD the value will be '0'.
Note: If you check disk type in a hypervisor environment results may show contradictory.
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:
Ubuntu
sudo apt install smartmontools
To start the service, run the command:
sudo /etc/init.d/smartmontools start
CentOS and RHEL
sudo yum install smartmontools
Fedora
sudo dnf install smartmontools
Smartd service will be started automatically after the installation. If not, use the following command to start the service:
sudo 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, the output will look like this:
Rotation Rate: Solid State Device
Conclusion
In this tutorial, we have learned how to check the disk type is SSD/HDD in the Linux system. SDD drives are expected to show 0 indicating no rotations and whereas HDD with platters rotates to show 1.
Thanks for reading. Let us know your feedback and suggestions in the below comment section.
Comments