When I check whether one of my server’s storage device is an HDD or an SSD, I use the following commands:
Step 1. Get device major:minor numbers:
$ stat /path/to/some/file/on/device ... Device: fd00h/64768d ...
Step 2. Use the device numbers to find the device under
$ ls -l /sys/dev/block/7:26 lrwxrwxrwx 1 root root 0 Apr 15 07:25 /sys/dev/block/7:26 -> ../../devices/virtual/block/loop26
where 7 is the major device number and 26 is the minor. From the above numbers, you can compute these using:
$ expr 64768 / 256 # major 253 $ expr 64768 % 256 # minor 0
Step 3. Find the
Now, if I look at the
../../devices/virtual/block/loop26 folder, I can search and find a rotational file. But first I rebuild the path properly. This means I want a full path rather than a relative path. As we can see, there are two
.. which means we go up two directories. The result is:
Lets look inside that folder:
$ ls /sys/devices/virtual/block/loop26 ... queue ...
We see a queue sub-directory, let’s look inside:
$ ls /sys/devices/virtual/block/loop26/queue ... rotational ...
rotational file exists, let’s print the content:
$ cat /sys/devices/virtual/block/loop26/queue/rotational 1
The loop device is considered to be a rotational (HDD) device!
IMPORTANT NOTE: In some cases, the queue sub-directory is one or two directories up. So the first
ls command may not show it. Try again after removing one sub-directory in your path. Repeat until you find a
queue sub-directory or the path is only 3 segments (
/sys/devices/virtual in my example).
So now I have a way to check the rotational file. When I test against my SSD drives on my server at home, I get
0 as expected. The disk is not rotational.
When I check on DigitalOcean, I get a
1 as if the drive in my VPS was a rotational (HDD) file. It should return
0. Just in case, I tested in VirtualBox on my server, and I get the same effect. If I create a disk in my VirtualBox server which is on an SSD, it does not recognize it as an SSD within VirtualBox. So I am thinking that both systems are using the same driver to simulate hard drives within the VPS…
Are there plans to fix this issue at DigitalOcean? I would need to know whether drive A is SSD or HDD and drive B is SSD or HDD and I would prefer not to have to indicate that information manually since this is prone to mistakes over time.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.