How To Find If The Disk Is SSD Or HDD In Linux
Picture this scenario. You are a newbie who have limited experience with Linux. You recently bought a new Laptop that has pre-installed with Linux, for example Ubuntu. You are not really sure whether the installed disk is SSD (Solid State Drive) or normal HDD (Hard Disk Drive). No problem! This brief guide will teach you how to find if the disk is SSD or HDD in Linux operating systems.
Find If The Disk Is SSD Or HDD In Linux
Starting from Kernel version 2.6.29, Linux operating systems can automatically detect SSD. There are a few ways to find to whether the disk is SSD or HDD. Here I have given 7 methods.
Method 1 – Check if the Disk is rotational
As you may already know, the traditional Hard Disk Drive (HDD) stores the data on a circular disc known as platter. When the disc spins, the moving read/write head will access the data. The faster the disk spins (rotates), the faster the hard disk works.
On the other hand, Solid State Drive (SDD) is modern storage technology and faster type of disk drive that stores the data on
So if you want to find whether the installed disk is SSD or normal HDD, just check if the disk is rotational using the following command:
$ cat /sys/block/sda/queue/rotational
If the output is 1, the disk is HDD. If the output is 0 (zero), the disk is SDD. Because, SSDs won’t rotate. So the output should be zero if you have SSD in your system.
Each drive has a directory in /sys/class/block/ location. So, you can check other drives details as well.
$ cat /sys/block/sdb/queue/rotational
$ cat /sys/block/sdc/queue/rotational
Method 2 – Using lsblk command
The lsblk command reads the sysfs filesystem and udev db to gather information about all available or the specified block devices. The lsblk command is part of the util-linux package and comes pre-installed with most Linux distributions.
Just in case if lsblk command is not available, just install util-linux package using your distribution’s package manager.
For example, on Arch-based systems, you can install it using command:
$ sudo pacman -S util-linux
On Debian-based systems:
$ sudo apt install util-linux
On RPM-based systems:
$ sudo yum install util-linux
$ sudo zypper install util-linux
Now, find if the disk is SSD or HDD using command:
$ lsblk -d -o name,rota
NAME ROTA loop0 1 loop1 1 loop2 1 loop3 1 loop4 1 loop5 1 loop6 1 loop7 1 loop8 1 loop9 1 loop10 1 loop11 1 loop12 1 loop13 1 loop14 1 loop15 1 loop16 1 loop17 1 loop18 1 loop19 1 loop20 1 sda 1 sr0 1
Here, “rota” means rotation device. If you get value of rota in the above output as 1, the disk is HDD. If the value is 0 (zero), then the disk is SSD.
Method 3 – Using SMART monitoring tools
The another way to find if the disk is SSD or HDD is using smartctl command. The smartctl is part of the S.M.A.R.T monitoring tools package, which is used to control and monitor S.M.A.R.T. enabled ATA and SCSI Hard Drives.
To install SMART monitoring tools on Arch Linux and its variants, run:
$ sudo pacman -S install smartmontools
On Debian, Ubuntu:
$ sudo apt install smartmontools
On RHEL, CentOS:
$ sudo yum install smartmontools
$ sudo zypper install smartmontools
After installing smartmontools package, run the following command to find if the disk is SSD or HDD:
$ sudo smartctl -a /dev/sda | grep 'Rotation Rate'
If the disk is SSD, you will get an output like below.
Rotation Rate: Solid State Device
If the disk is HDD, you will get this output:
Rotation Rate: 5400 rpm
Method 4 – Using dmesg + Google
This is not a direct approach to find the disk type. In this method, we use dmesg command to find the disk model and then google the details to find if the disk is SSD or HDD.
$ dmesg | grep -i -e scsi -e ata
You will see the disk model name among all other details.
[...] [ 1.845159] scsi 0:0:0:0: Direct-Access ATA ST9500325AS DEM1 PQ: 0 ANSI: 5 [...]
Just google this model to find the disk details.
Method 5 – Using SCSI details + Google
This is same as the above method. We retrieve the disk model from /proc directory using command:
$ cat /proc/scsi/scsi
Attached devices: Host: scsi0 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST9500325AS Rev: DEM1 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi4 Channel: 00 Id: 00 Lun: 00 Vendor: PLDS Model: DVD+-RW DS-8A8SH Rev: KD11 Type: CD-ROM ANSI SCSI revision: 05 Host: scsi6 Channel: 00 Id: 00 Lun: 00 Vendor: Generic- Model: Multi-Card Rev: 1.00 Type: Direct-Access ANSI SCSI revision: 00
And then Google the details to know if the disk is SSD or HDD.
Method 6 – Using Sg3-utils
Sg3-utils is a collection of utilities for devices using the SCSI command set. Each utility in this package implements one SCSI command.
Sg3-utils is available in the default repositories of Debian and Ubuntu. To install it on your system, simply run:
$ sudo apt install sg3-utils
Now, check for Vital Product Data (VPD) for the block device characteristics by running the following command:
$ sudo sg_vpd --page=bdc /dev/sda
Block device characteristics VPD page (SBC): Nominal rotation rate: 5400 rpm Product type: Not specified WABEREQ=0 WACEREQ=0 Nominal form factor not reported ZONED=0 BOCS=0 FUAB=0 VBULS=0
Go through the output. If the output contains this line – “Nominal rotation rate: 5400 rpm”, it is HDD. For SSD, you probably would see – “Non-rotating medium”.
Method 7 – Benchmark Disk Access Performance
Find if the disk is SSD or HDD by reading random blocks from the disk using command:
time for i in `seq 1 1000`; do dd bs=4k if=/dev/sda count=1 skip=$(( $RANDOM * 128 )) >/dev/null 2>&1; done
This command will read 1000 random 4k blocks from first 16GB of a disk.
If your disk is SSD, the operation should complete in about a second. If the disk is HDD, then it will take a few seconds to complete.
This will be helpful to check disks in your VPS. If you’re using a VPS and wanted to check if the hosting provider gave you whether SSD or HDD, this is one way to find out!
What if there are multiple disks?
What If I have two disks, one is SSD and another is HDD? Both disks are same size and from the same manufacturer. I don’t know on which disk my Linux is installed. In that case, simply find on which disk the root filesystem is located using the following command:
$ df / -h
Filesystem Size Used Avail Use% Mounted on /dev/sda1 458G 341G 95G 79% /
Alternatively, use lshw command to find more details about the disks:
$ sudo lshw -short -C disk
H/W path Device Class Description ==================================================================== /0/100/1d/1/1/6/0.0.0 /dev/sdb disk Multi-Card /0/100/1d/1/1/6/0.0.0/0 /dev/sdb disk /0/1/0.0.0 /dev/sda disk 500GB ST9500325AS /0/2/0.0.0 /dev/cdrom disk DVD+-RW DS-8A8SH
As you see in the above output, my root filesystem is installed in /dev/sda. Now follow any one of the above methods to find if the disk is HDD or SSD.
In some new Laptops like Lenovo ideapad s240, you will see a different device name, for example nvme0n1. Let us view the list of available block devices using command:
$ ls /sys/block
loop0 loop11 loop14 loop17 loop2 loop3 loop6 loop9 loop1 loop12 loop15 loop18 loop20 loop4 loop7 nvme0n1 loop10 loop13 loop16 loop19 loop21 loop5 loop8
Let us find out on which disk the root filesystem is located:
$ df / -h
Filesystem Size Used Avail Use% Mounted on /dev/nvme0n1p6 96G 34G 58G 34% /
As you see in the above outputs, there is no sda or sdb. Don’t panic! This is normal. The /dev/nvme… device name indicates newer NVMe “disks.” If the disk is connected through an NVM Express port instead of a traditional SATA or SAS port, you will see a different device name as shown in the above output.
Here, /dev/nvme0n1 is equivalent to to /dev/sda. Hence, /dev/nvme0n1p6 is equivalent to /dev/sda6.
- How To Find Hardware Specifications On Linux
- How To Check If A Linux System Is Physical Or Virtual Machine
- How To Check If A Linux System Is 32 bit Or 64 Bit
- How To Find If A CPU Supports Virtualization Technology (VT)
Hope it was useful.