sdparm的硬盘状态信息

时间:2015-03-30 17:18:32

标签: linux centos7

我有一个用于备份的外部硬盘,它通过USB与我的linux计算机连接。因为hdparm无法正常工作,所以我尝试使用sudo sdparm -C stop /dev/sdf1来关闭磁盘。我怎样才能知道磁盘现在是否真的在睡觉?

1 个答案:

答案 0 :(得分:0)

如果您不想使用hdparm,也可以使用smartctl收集此信息。

为了做到这一点,你可以运行类似的东西:

 sudo smartctl  -a  -n sleep /dev/sda

您基本上对-n参数感兴趣,该参数包含以下文档。

   -n POWERMODE, --nocheck=POWERMODE
          [ATA only] Specifies if smartctl should exit before performing any checks when the device is in a low-power mode. It may be used to  prevent
          a  disk  from being spun-up by smartctl. The power mode is ignored by default.  A nonzero exit status is returned if the device is in one of
          the specified low-power modes (see RETURN VALUES below).

          Note: If this option is used it may also be necessary to specify the device type with the ´-d´ option.  Otherwise the device may spin up due
          to commands issued during device type autodetection.

          The valid arguments to this option are:

          never - check the device always, but print the power mode if ´-i´ is specified.

          sleep - check the device unless it is in SLEEP mode.

          standby  -  check the device unless it is in SLEEP or STANDBY mode.  In these modes most disks are not spinning, so if you want to prevent a
          disk from spinning up, this is probably what you want.

          idle - check the device unless it is in SLEEP, STANDBY or IDLE mode.  In the IDLE state, most disks are still spinning, so this is  probably
          not what you want.