How to know if a disk is an SSD or an HDD

I want to know whether a disk is a solid-state drive or hard disk.

lshw is not installed. I do yum install lshw and it says there is no package named lshw. I do not know which version of http://pkgs.repoforge.org/lshw/ is suitable for my CentOS.

I search the net and there is nothing that explain how to know whether a drive is SSD or HDD. Should I just format them first?

Result of fdisk -l:

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00074f7d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          14      103424   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              14         536     4194304   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             536       14594   112921600   83  Linux

Disk /dev/sdc: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdb: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdd: 480.1 GB, 480103981056 bytes
255 heads, 63 sectors/track, 58369 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Linux automatically detects SSD, and since kernel version 2.6.29, you may verify sda with:

cat /sys/block/sda/queue/rotational

You should get 1 for hard disks and 0 for a SSD.

It will probably not work if your disk is a logical device emulated by hardware (like a RAID controller).

See this answer for more information about SSD partitioning, filesystem…

Method 2

With lsblk (part of the util-linux package):

lsblk -d -o name,rota

NAME ROTA
sda     0
sdb     0
sdc     1

where ROTA means rotational device (1 if true, 0 if false)

Method 3

Use smartctl (install by installing smartmontools) to retrieve vendor information,

sudo smartctl -a /dev/sdb

If you see a line like this,

Rotation Rate: Solid State Device

That would be a SSD drive.

Method 4

I needed to do this on the VPS and none of the provided solutions worked for me, but this answer did the trick:

https://serverfault.com/questions/551453/how-do-i-verify-that-my-hosting-provider-gave-me-ssds/551495#551495

This just reads random data from the drive and assesses the time.

time for i in `seq 1 1000`; do
    dd bs=4k if=/dev/sda count=1 skip=$(( $RANDOM * 128 )) >/dev/null 2>&1;
done

NOTE: You may need sudo before the dd command, depending on your permissions.

Here are my results for an SSD:

real    0m1.375s
user    0m0.285s
sys     0m0.944s

And a HDD:
real    0m14.249s
user    0m0.752s
sys     0m6.284s

As you can see, the HDD takes about 10x the duration. This may not be reliable for some very fast HDD’s, but in general, it will give you a good idea.

Method 5

The other answers already tell you how to get this information in a number of ways , including /proc. But you must expect all these mechanisms to lie if there’s any virtualisation in the way, such as a hybrid SAN array with multiple tiers, or if the Linux machine is a virtual machine (where Linux will probably report the disk as a basic SCSI rotating disk, regardless of what the hardware really is)

Method 6

check cat /proc/scsi/scsi. there you should see the exact model of your disk. then you just google the model to find info about it.

Method 7

This is an old post but I wanted to share another way to do this which I found out by accident:

sg_vpd --page=bdc /dev/sda

This commands fetches the Vital Product Data for the block device characteristics. For a rotating head disk, the output will include:
Nominal rotation rate: 7200 rpm
For an SSD, it will include:
Non-rotating medium (e.g. solid state)

Method 8

Type this in your Linux terminal:

cat /proc/scsi/scsi

Like mine:
$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST1000LM024 HN-M Rev: 0004
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: SAMSUNG SSD PM83 Rev: 3D1Q
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: HL-DT-ST Model: DVD+-RW GT80N    Rev: A103
  Type:   CD-ROM                           ANSI  SCSI revision: 05

You can see the model of your hard drive if it is SSD or HHD.

Method 9

find /sys/block/* -maxdepth 1 -exec echo {} ; -exec grep '0' {}/queue/rotational ; | grep -B1 '^0' | grep '^/' | sed 's/^.*///g'

This searches all block devices and check to see if it is rotary (1); if not (0) it is ssd.

This only displays discs marked as ssd.

Method 10

If you want to be lazy and realy want to read something like ssd or hdd
give

sudo lshw -short -C disk

a try.

My Output shows both:

H/W path         Device      Class          Description
=======================================================
/0/100/17/0      /dev/sda    disk           1TB TOSHIBA MQ01ABD1
/0/100/17/1      /dev/sdb    disk           128GB SSD PHISON 128GB
/0/100/17/0.0.0  /dev/sr0    disk           DVDRAM GUD0N


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x