UNIXETC

树莓派硬盘测速

在树莓派上测试硬盘速度可以帮助你了解存储设备的性能。以下是两种常用的方法:

使用hdparm测速

hdparm 是一个用于测试磁盘读写速度的工具。

安装hdparm

sudo apt install hdparm

使用hdparm测速

root@raspi2b ~# lsblk  #检查设备名
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
mmcblk0     179:0    0 29.3G  0 disk
├─mmcblk0p1 179:1    0  128M  0 part /boot/firmware
└─mmcblk0p2 179:2    0 29.2G  0 part /
root@raspi2b ~# sudo hdparm -Tt /dev/mmcblk0  #使用hdparm测速

/dev/mmcblk0:
 Timing cached reads:   1026 MB in  2.00 seconds = 512.59 MB/sec
 Timing buffered disk reads:  64 MB in  3.09 seconds =  20.68 MB/sec

以上实例中,/dev/mmcblk0代表SD卡存储设备。-T 代表从缓存读取速度,-t 代表从目标位置的读取速度。

使用dd命令测速

root@raspi2b ~# sudo dd if=/dev/mmcblk0 of=/dev/null bs=1M count=1024 status=progress
1065353216 字节 (1.1 GB, 1016 MiB) 已复制,48 s,22.2 MB/s
输入了 1024+0 块记录
输出了 1024+0 块记录
1073741824 字节 (1.1 GB, 1.0 GiB) 已复制,48.3631 s,22.2 MB/s

以上实例中,if=/dev/mmcblk0 指定输入文件为 SD 卡设备,of=/dev/null 将读取的数据丢弃,bs=1M 设置块大小为 1MB,count=1024 读取 1024 个块,总计 1GB 数据,status=progress 显示进度信息。

更多文章