There are different types of disk drives available among which the 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
The lsblk command is used in Linux to print all available or specified block devices. To check disk is SSD or HDD, use lsblk command with -d and -o option, this will display specific information about your disk.
You can use lsblk command with rota column to check your drive rotational (1 indicates HDD) and (0 indicates SSD).
lsblk -d -o name,rota,size,type,mountpoints
In this command -d option is used to remove partition nodes and -o option means to output columns. The columns I have used the command are name (name of the block device), rota ( show if your drive is rotational or not), size (size of block device), type ( can be physical or virtual or rom etc), mountpoints (where device mounted in file system).
From the output, you can understand that both sda and sdb are rotational drives indicated in the ROTA column with '0'. 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.
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:
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, the output will look like this:
Rotation Rate: Solid State Device
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.