2

As hdparm does not work for my USB external drive (it spins down too early), I’d like to simulate stand-by control manually by a simple script with the following idea:

  • monitor I/O to the disk
  • when, except for the script itself, there is no I/O from other processes for some time, produce dummy I/O to keep disk alive
    • after some time let drive spin down
    • the dummy I/O should at best be nothing that actually reads or writes to disk (and therefore moves the mechanics producing wear-out) but maybe read some status etc.

I’m not experienced enough in Bash scripting to know which commands could be used. Any suggestions? The system is Arch Linux.

1
  • Does smartctl work? That is, does smartctl -d sat --all show disk info? If it does, there is -g option to modify apm settings. – Toni Jun 6 '15 at 15:28
1

(I am aware this question is over 2 years old, however the problem is still actual)

I am using the following code for my drive that doesn't respect smartctl settings:

#!/bin/bash
while :
do
        date +%s > /second_drive/keepalive_linux.txt
        sync
        sleep 2
done

To make it run at startup, I used:

EDITOR=nano crontab -e

And added:

@reboot bash /path/to/script.sh

(the drive is NTFS formatted, by the way)

It is the same behaviour that KeepAliveHD for Windows has.

While it could be done in a better way (like the OP described), it's better than nothing for now.

0

Google should get the credit for this one:

http://www.unix.com/programming/161666-tool-simulate-non-sequential-disk-i-o-simulate-db-file-sequential-read-c-posix.html

#!/bin/bash
for ((N=0; N<10; N++))
do
        dd if=gigabytefile of=/dev/null skip=$((RANDOM % 1024)) bs=$((1024*1024)) count=1
done
1
  • Sorry, but this seems completely unrelated. – user905686 Apr 4 '15 at 12:52

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.