多硬盘 嵌入式DVR 如何控制硬盘工作状态(主要是停转和启动)

 

多硬盘 嵌入式DVR 如何控制硬盘工作状态(主要是停转和启动) 以达到省电并且保护硬盘,延长硬盘寿命的目的。

以海思芯片为例子,3515 3520内置SATA控制器 而3512 3511 上面的硬盘一般是通过PCI 转SATA出来的,SATA与内置的从软件角度看没什么区别。

 

所以都可以直接向其SATA控制器 发送命令,让他停转与启动。

 

 

命令可以在自己的程序中发送,如果你懒的话,也可以借用sdparm utility 工具包来完成。

 

比如我的硬盘 在/dev/sda 节点上

 

那么 

sdparm -C stop /dev/sda 就可以让他停止

sdparm -C start /dev/sda 就可以让他重新启动,开始工作

 

注:这个工具工需要自己下载,交叉编译。

 

 

sdparm 相关的使用,网上有详细的说明:http://sg.danny.cz/sg/sdparm.html#mozTocId926648

 

IDE硬盘现在用的少了,不过它肯定也少不了 有hdparm 对他进行控制。

 

当然,如你的机器没有真正的SATA控制器(如USB转出来的,类似一个读卡器),我试过,没办法让他停转,不知道各位有没有方法

 

让USB--->SATA 这种方式的硬盘进入休眠模式,有的话,请留言。谢谢

 

sdparm commands

The '--command=' option allows a command to be sent to the given device. The currently supported commands are:

  • capacity: sends a READ CAPACITY and if successful reports the number of blocks, block length and capacity expressed in MibiBytes (1048576 bytes). Valid for disks and CD/DVD drives with the appropriate media loaded.
  • eject: stops the medium (if it is spinning) and ejects it from the drive. Note that this may be prevented by software in which case use the 'unlock' command first.
  • load: loads the medium and then spins it up
  • profile: lists the profiles (e.g. DVD+R and DVD-RAM) supported by a CD/DVD/HD_DVD/BD drive. If media is present in the drive then its corresponding profile has an asterisk ("*") to its right in the list.
  • ready: reports whether the medium is ready for IO. Ready usually means that it is present and spun up. If the device is not ready then the exit status will be 2 (see exit status section below).
  • sense: reports sense data (from a REQUEST SENSE SCSI command); can include power condition information, a progress indication for a time consuming command (e.g. format) or a report an informational exception (when MRIE=6)
  • speed: takes and argument (e.g. --command=speed=1350 or -C sp=1350 ) which is in kilobytes per second (1000 bytes per second units). Attempts to set CD/DVD/BD media to given read speed. If argument is zero then set drive back to its optimum setting. "Times one" speeds are 177 kB/s for CD, 1350  kB/s for DVD and 4500 kB/s for HD-DVD and BD.
  • start: spin up the medium
  • stop: spin down the medium (may require the --readonly option)
  • sync: send a SYNCHRONIZE CACHE SCSI command to the device.
  • unlock: instructs the device to allow medium removal (i.e. an eject). Beware, the OS may have had a good reason for preventing removal of the medium (e.g. it contains a mounted file system). Use at your own risk.

The command names can be abbreviated to two letters unless that leads to ambiguity (e.g. start and stop can be abbreviated to sta and sto).

Due to some quirks introduced in linux around lk 2.6.30 (but not necessarily by the kernel itself) using 'sdparm --readonly --command=stop /dev/sdc' may be required to spin down an ATA disk (behind a SAT layer). Without the '--readonly' option nuisance commands are sent to the ATA disk when the sdparm invocation completes and these restart the disk.

These sdparm commands send SCSI commands to the given DEVICE. If they don't seem to work, adding a verbose flag (i.e. '-v' or '-vv') may provide more information. The "ready" and "sense" commands need read permissions on the DEVICE while the other commands need both read and write permissions.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值