2

Once every few days, seemingly at random, our backup to an external USB hard disk fails on our hp DL380 G5 server running CentOS 6.4 64-bit. If I cd /mnt/backup and run ls it complains ls: reading directory .: Input/output error, but mount -l reports /dev/sda1 on /mnt/backup type ext4 (rw). When I get someone on-site to check it out, they invariably report that the light on the external drive is slowly blinking, which is apparently normal for a sleep state. But I don't ask it to go into a sleep state until after rsnapshot runs, but rsnapshot causes my script to fail before that even has a chance to happen. Is it trying to save power? How can I get it to not do this?

rsnapshot complains:

/usr/bin/rsnapshot daily: ERROR: /mnt/backup/.snapshots does not exist.

Of course, if the person on-site unplugs and replugs the drive, I can remount it, and .snapshots certainly does exist and rsnapshot will run without errors. For a while until the next random occurrance, that is. BTW, this is a pretty new WD Passport drive.

So how do I tell it to stay awake?

1

If this hw poweroff were a normal function of the linux kernel, it handled it correctly. No, I think it is a wonderful surprise from the HP hardware.

I suggest a trivial workaround. Put into crontab:

* * * * * dd if=/dev/sda of=/dev/null bs=512 count=1

This will read in the partition table of the pendrive in every minute. It won't drop the life of the pendrive, because it made only read operations from it, but will prevents its sleep mode to turn on.

In my systems I never handled a such problem. If a pendrive was mounted, it was mounted, and if I forgot it and tried to use its partition after 2 weeks, it was able to be turned on, without a single kernel warning.

| improve this answer | |
  • 1
    Not ideal, but in the absence of getting at the root of the problem, I'll bite, so thank you for your answer. :) In my case rather than a pendrive, this is actually a traditional HD. Will it shorten its life, reading the same block so often? I'm guessing not because it probably caches it anyway. – Kev Jan 7 '14 at 16:44
  • 1
    No, it will come from the firmware cache of the hd. – peterh - Reinstate Monica Jan 30 '14 at 15:31
4

Maybe the best thing to prevent hd sleep and firmware caching is the reading of a random sector of your disk:

* * * * * bash -c 'dd if=/dev/sda of=/dev/null count=1 skip=$RANDOM'

It worked just fine for me.

| improve this answer | |
  • How is this better than the accepted answer ? – user186340 Oct 2 '14 at 9:11
  • "to prevent [...] firmware caching" - that's how it's better. – Eugene Pakhomov Oct 16 '18 at 6:44

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.