How to know if a disk is an SSD or an HDD Linux Centos 7

I needed to do this on the VPS and none of the provided solutions worked for me,

this answer did the trick

so, it is about reading random data from the drive and assessing 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;

here are my results for SSD

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

and HDD

real    0m14.249s
user    0m0.752s
sys     0m6.284s

Leave a Reply