9

I searched and found 2 options, none of which I'm confident provided me the answer.

1: cat /sys/block/sda/queue/rotational

This output '1' to stdout. What does this mean?

2: lshw -class disc

but couldn't find anything that answers my question.

MDMoore313
  • 5,581
  • 6
  • 36
  • 75
Amir Bar
  • 213
  • 2
  • 7

2 Answers2

18

Let's try to read 1000 random 4k blocks from first 16GB of a disk:

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 is something that should be very slow on rotating drive in comparison with SSD. On my desktop class SSD it ends in about a second. On desktop class 7200rpm rotating drive it ends in 10 seconds.

Tometzky
  • 2,679
  • 4
  • 26
  • 32
  • thank I got these respone: `real 0m1.632s user 0m0.336s sys 0m0.939s` it mean i am on ssd? – Amir Bar Nov 08 '13 at 08:37
  • 1
    I'm pretty sure you are. – Tometzky Nov 08 '13 at 12:44
  • on my VM whose virtual disk is placed on an HDD it takes only ~1.5s to complete this so it's not correct – phuclv Dec 06 '16 at 02:27
  • 1
    You might need to make sure that you have data there. Unused space on a VM volume might be using sparse files or equivalent technology - that would fool this check. Also if there are like 10+ drives in RAID behind this, which would share load, then it's not that easy to distinguish it from single SSD. – Tometzky Dec 07 '16 at 17:16
  • That hides all errors :D So you can measure error reporting time: `dd: failed to open ‘/dev/sdb’: Permission denied` – filimonov Apr 20 '20 at 07:13
4

In a physical machine (not a VPS), you can get the type with smartctl:

smartctl -a /dev/sda

and grep for Rotation:

smartctl -a /dev/sda | grep Rotation
Rotation Rate:    Solid State Device

smartctl -a /dev/sdb | grep Rotation
Rotation Rate:    5400 rpm

It's quite likely you have no chance to identify the disk type inside a VPS, as the hypervisor abstracts the real hardware away from the guest machines.

Sven
  • 98,649
  • 14
  • 180
  • 226
  • there is nothing i can install for exmaple that will check the write speed or something? becuose i am afraid that he gave me normal hd when he promised for ssd – Amir Bar Nov 07 '13 at 19:15
  • 2
    It's somewhat difficult inside a VPS because there are many factors affecting the disk speed, but at least the access times *should* be significantly better with a SSD as compared to normal disks. Try `bonnie++` etc. – Sven Nov 07 '13 at 19:29
  • 3
    @amirbar you have to remember also that your VPS could be distributed amongst *several* drives and/or CPUs, I wouldn't worry too much about physical hardware as I would *actual performance* of the service you're trying to run on the VPS. SSDs are nice but not necessarily a requirement for *most* services. – MDMoore313 Nov 07 '13 at 19:33