Files
Linux/Docs/测试磁盘是否为SSD.md
offends cee91802b3
Some checks failed
continuous-integration/drone Build is failing
synchronization
2025-08-25 15:57:40 +08:00

83 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本地作者;丁辉
# 测试磁盘是否为SSD
## 方法一
> 判断cat /sys/block/*/queue/rotational的返回值其中*为你的硬盘设备名称例如sda等等如果返回1则表示磁盘可旋转那么就是机械硬盘HDD了反之如果返回0则表示磁盘不可以旋转那么就有可能是固态硬盘SSD了。
```bash
grep ^ /sys/block/*/queue/rotational
```
## 方式二
1. 安装sysbench
```bash
yum install -y sysbench
```
2. 选择要测的磁盘路径 /opt
```bash
cd /opt
```
3. 建文件
> 准备阶段IO测试,线程数为40,创建大小为500M的测试文件64个,共32G,使用了随机读写模式(rndrw)测试300s执行完后会在当前目录下生成一堆小文件。
```bash
sysbench --test=fileio --file-total-size=32G --file-test-mode=rndrw --max-time=300 --max-requests=0 --file-block-size=16K --file-num=64 --num-threads=40 prepare
```
4. 测 IO
```bash
sysbench --test=fileio --file-total-size=32G --file-test-mode=rndrw --max-time=300 --max-requests=0 --file-block-size=16K --file-num=64 --num-threads=40 run
```
5. 输出结果
```bash
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
WARNING: --max-time is deprecated, use --time insteadsysbench 1.0.17 (using system LuaJIT 2.0.4)
Running the test with following options:
Number of threads: 40
Initializing random number generator from current time
Extra file open flags: (none)64 files, 512MiB each32GiB total file sizeBlock size 16KiBNumber of IO requests: 0Read/Write ratio for combined random IO test: 1.50Periodic FSYNC enabled, calling fsync() each 100 requests.Calling fsync() at the end of test, Enabled.Using synchronous I/O modeDoing random r/w testInitializing worker threads...
Threads started!
File operations:
reads/s: 36369.44
writes/s: 24246.29
fsyncs/s: 38802.60
Throughput:
read, MiB/s: 568.27
written, MiB/s: 378.85
General statistics:
total time: 300.0042s
total number of events: 29824059
Latency (ms):
min: 0.00
avg: 0.37
max: 8.21
95th percentile: 1.96
sum: 11174442.44
Threads fairness:
events (avg/stddev): 745601.4750/1916.86
execution time (avg/stddev): 279.3611/0.06
```
6. 解读
读写次数在2万~4万间吞吐量在300~600M/s可以判定磁盘为SSD。