在linux系统中是如何分辨出每个盘符的类型的:
可以通过查看 /sys/block/[盘符]/queue/rotational 的内容,内容为“1”则为HDD,为“0”则是SSD。
简单举例 以下是实现查找系统挂载的所有的SSD并使用smartctl 命令显示smart 属性信息。
for var in a b c d e fdoif [ -d "/sys/block/sd$var" ]thenread num < /sys/block/sd$var/queue/rotationalif [ $num == 0 ]thenecho "Get the SSD smart attribute of /dev/sd$var ..."smartctl -A /dev/sd$varfifidoneecho