Sometimes, you might need to know if you are using Solid State Drive (SSD) or Hard Disk Drive (HDD) on your system. If so, checking the type of disk drive is quite easy on Linux. There are different methods to verify and check if you are using an SSD or HDD. The Linux operating system can automatically detect SSD since the kernel 2.6.29 was introduced.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux system SSD health checks queries.
In this context, we shall look into different methods to check if it is an SSD or HDD on Ubuntu 20.04 LTS server.
To check the disk type if it is SSD or HDD in Linux, we can use lsblk command. It is due to the rotational feature of the disk. If the lsblk command is not found on your Linux distribution like Ubuntu 20.04 then you can install it with the command:
$ sudo apt install util-linux
Then to check the disk types, run the following command by using lsblk:
$ lsblk -d -o name,rota
To be clear, if the ROTA value is 1, then your disk type is HDD and if the ROTA value is 0 then it is SSD. Here, you can see 1 on the above screenshot for the ROTA value of sda, vda which means it is HDD.
Hard disk drive (HDD) works with the rotation of the disk while SSD does not have such rotational disk. To verify if you are using an SSD or HDD, you have to check if it is rotational or not. If it is rotational then the value must be 1, if not then it is 0.
To check that value, you have to print the value of /sys/block/sdX/queue/rotational. For further details, run the command:
$ cat /sys/block/sda/queue/rotational
Here, the value is 1 which means the disk type is Hard disk drive(HDD). If the value is 0 then it is an SSD.
Another example of checking if the disk is rotational, run the command:
$ cat /sys/block/vda/queue/rotational
Here, the value is also 1 which means the disk type is Hard disk drive(HDD). If the value is 0 then it is an SSD.
This is the smart way to check the disk type if it is SSD or HDD. As the smart monitoring tool is such a package which consists of the unique command line tool called smartctl. So to install such a tool on ubuntu 20.04 LTS server, you can run the command:
$ sudo apt install smartmontools -y
Now check if the smartd service is running or not with the following command:
$ sudo systemctl status smartd
If it is not active by default, you can start it with the command:
$ sudo systemctl start smartd
As the smartd service is running, run the command as shown below to check if you are using HDD or SSD:
$ sudo smartctl -a /dev/sda | grep 'Rotation Rate'
Here, we are checking for drive sda.
With the above command, if the drive is SSD then the output will be:
Rotation Rate: Solid State Device
And, if the drive is HDD then the output will be:
Rotation Rate: 5400 rpm
This article covers the different methods to check if the disk is HDD or SSD in a Linux operating system like Ubuntu 20.04 LTS server. In fact, Checking SSD/HDD health in Linux will help you to identify failed drives and they can be replaced before any data loss occurs. Therefore, If you are a system administrator and responsible for managing Linux systems in Datacenter, then, it is recommended to check the health of the SSD and HDD drives regularly.
Checking SSD/HDD health in Linux will help you to identify failed drives and they can be replaced before any data loss occurs.
How to use SMART monitoring tools in Linux ?
Smart monitoring tools is a control and monitoring utility for SATA, SCSI hard drives and solid state drive. The tool comes with a command called 'smartctl'.
Use yum to check which package provides smartctl command:
# yum provides smartctl
The output will suggest that smartmontools is the package that distributes smartctl command.
To Install smartmontools, run:
# yum install smartmontools
Use smartctl command:
# smartctl -a /dev/sda