6

I've looked through the manual for hdparm, sdparm. I know there are arguments to spin down the drive, with -y and -Y. I also know there are arguments to control the power saving features, such as -S and -B. However what I want is to start the motor and spin up the drive.

sdparm

I see sdparm's manual page has load and start parameters. Can either of these be used? It seems more like something appropriate for a tape drive, or at beast an optical drive?

dd

dd if=/dev/hdX of=/dev/null count=512 seems the best answer according to What command do I use to spin up a "power up in standby" drive? However, when this is already in the cache, then the drive will not spin up.

It seems strange there is no command to explicitly tell the device to start the motor/spin up.

What is the best way to spin up SATA HDDs in GNU/Linux?

  • I have an idea: What about using FUA (Force Unit Access) and then do a read from anywhere? Wouldn't this bypass all buffers, even the cache on the disk itself? Of course the disk has to support FUA, and then there is the problem of how to perform a manual FUA access. But surely there must be something more simple and better? – AttributedTensorField May 27 '14 at 1:49
5

Read from the raw disk device instead of the block device. This bypasses the kernel buffer cache and guarantees that the drive will spin up.

  • How do you do this on a system that has no /dev/raw*? Also, why would this spin up the disk if the disk has the data already in its own cache? Wouldn't it depend on the particular firmware of that particular disk if it decides it wants to spin up or not? – AttributedTensorField May 27 '14 at 1:44
  • Without /dev/raw I think you're out of luck. As for disk buffer cache, it's hard to say. I'm used to using kernels that disable on-disk cache, but it's possible that the drive won't spin up if that cache is used. A further complicating factor are the hybrid drives that use flash+rotating rust. – Kyle Jones May 27 '14 at 1:50
3

dd's direct flag ought to bypass the (host) cache, and force I/O to be sent to the drive:

dd if=/dev/sda bs=4096 count=1 of=/dev/null iflag=direct
                                            ^^^^^^^^^^^^

Testing on my machine, this definitely makes the disk activity light blink. It doesn't blink (at least the second time) without the iflag.

0

1) First, if you can do it easily, I suggest to do what Kyle Jones says: read directly from the raw device.

2) If you can't do that, read from a randomly selected position of the drive (f.e.: dd if=/dev/diskdev of=/dev/null seek=$[173<<30] bs=1048576 count=1024 will read in a giga from the 173. giga of the disk). This makes very probably, that the actual read data isn't in the actual read cache, thus the drive need to be spinned up to fill the read operation.

If you want to be sure, you could read from multiple times, selected randomly data.

3) As an alternative, you can read from a fixed position (for example: from the beginning of the disk) with the same dd command, but always at least so many, as many RAM you have. This guarantees, that there will be some disk region to read, which surely isn't in the actual disk read cache, thus the disk need to be spinned up to read them.


In your place (if 1 isn't available) I did (3) if I need very precision and (2) if I only played on my home linux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.