Skip to content

threefoldtech/seektime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Seektime

This tool try to determine if a target device is a HDD or SSD disk.

Actually, this tool just try to determine if the device behind a file (whatever it is) is 'slow' or 'fast' doing seek and single sector read.

This test is not accurate. This tool output SSD or HDD based on the seektime, but this is just an approximation. The nature of the device is absolutly not tested, all of this is pure speculative and guessing.

Purpose

It's quite easy, using Linux, to know if a disk is rotational using /sys/block/<device>/queue/rotational endpoint, but sometime, when using like RAID Controller or any hardware which hide this, this value is fake.

This tool try, in a generic way, to probe if it's a HDD or SSD (by SSD, understand any non-slow-rotational device) in case of difficult hardware. Since RAID Controller, etc. are all different, it's difficult to find a generic way.

How does this work

This tool simply seek on the disk and compute the time it took. Here is a computed average of seek-time based on rotational disk, in average:

RPM Seek Time
5400 6 ms
7200 5 ms
10000 3 ms
15000 2 ms

When using any non-rotational disks, seektime is nearly null since there are no mechanical part which needs to move.

This tool use the following assumption: if computed seektime is lower than 0.5 ms, we assume it's an SSD.

In order to have more relevant value, the test does 128 seek-read, not only one. All of theses seek are randomly spread over the disk, to try to avoid as much as possible hardware cache.

In addition, each time before doing any seek/read, we ask the kernel to purge any page cache related to this disk.

Install

Just compile the code with make, there are no extra dependencies than a C Compiler (tested with gcc).

Example

Basic computer using one SSD and one HDD

~ # for dev in /dev/sd?; do ./seektime $dev; done
/dev/sda: SSD (103 us)
/dev/sdb: HDD (3336 us)

Here are the physical disks

  • /dev/sda: SanDisk SDSSDA240G
  • /dev/sdb: WDC WD7500BPKT-00PK4T0

Dell Server using PERC RAID Controller

This controller can't do passthrough and gives fake values for rotational and disk name, there are no default (kernel) way to know what's behind. Some queries needs to be done using megaraid driver.

This server contains 12 HDD and 2 SSD:

~ # for dev in /dev/sd?; do ./seektime $dev; done
/dev/sda: HDD (1671 us)
[...]
/dev/sdj: HDD (2721 us)
/dev/sdk: HDD (3061 us)
/dev/sdl: HDD (2827 us)
/dev/sdm: SSD (37 us)
/dev/sdn: SSD (32 us)

Physical disks are:

  • 12x HGST HUS726060ALS640
  • 2x Samsung SSD 860 EVO 2TB

Dell Server LSI MegaRAID SAS-3

You can get a JSON response via -j option as well.

# for i in /dev/sd? /dev/nvme?n1; do ./seektime -j $i; done
{"device": "/dev/sda", "type": "HDD", "elapsed": 5737, "mintime": 212, "maxtime": 11139}
{"device": "/dev/sdb", "type": "HDD", "elapsed": 5288, "mintime": 201, "maxtime": 9937}
{"device": "/dev/sdc", "type": "HDD", "elapsed": 5518, "mintime": 274, "maxtime": 10698}
{"device": "/dev/sdd", "type": "HDD", "elapsed": 5579, "mintime": 205, "maxtime": 10642}
{"device": "/dev/sde", "type": "HDD", "elapsed": 5899, "mintime": 282, "maxtime": 11971}
{"device": "/dev/sdf", "type": "HDD", "elapsed": 5461, "mintime": 215, "maxtime": 10529}
{"device": "/dev/sdg", "type": "HDD", "elapsed": 6320, "mintime": 278, "maxtime": 10916}
{"device": "/dev/sdh", "type": "HDD", "elapsed": 5744, "mintime": 170, "maxtime": 11340}
{"device": "/dev/nvme0n1", "type": "SSD", "elapsed": 69, "mintime": 15, "maxtime": 91}
{"device": "/dev/nvme1n1", "type": "SSD", "elapsed": 108, "mintime": 73, "maxtime": 521}
{"device": "/dev/nvme2n1", "type": "SSD", "elapsed": 99, "mintime": 74, "maxtime": 1475}

The field elapsed is the average time, this field will maybe be renamed later.

Repository Owner