Waking Up USB External Hard Drive for file archiving

Hello Experts,

I hope I'm writing to the correct category for my question.

I have a very basic shell script for doing file archiving to the external usb hard drive (WD studio edition II 2TB formatted as FAT32 for compatibility). The shell script only needs to run once per day. It basically downloads some data from a server and converts it to a different format files then makes separate folders for every day on the external disk then copies the converted files to those folders. The problem is drive goes to sleep when idle and I cannot wake it up with normal commands such as "ls" or "cd /media/DISK" or "mkdir -p /media/DISK/somefolder" etc. mkdir command gives input/output error.

If I run "fdisk -l" command as root then the drive starts to spin and I can run the script successfully. But this is not ideal since I would like to put this script to a cronjob and let it run once per day.

Do you have any advice for waking up the disk before running the script?

Best regards

Edit: OS: Centos 5.8 64 bit

What's wrong with using fdisk -l to start the disk spinning? Should it be permissions, any command to make the kernel interact with the disk will need them.

So there is no way to wake the disk without root permission?
It seems I have to put the fdisk command into my script then find a way to run it as root without asking root password...which I don't know how.

Either create a sudoers entry for your cron user, or run a root's cron job a minute before your other job.

1 Like

It wont ask root its passwd if the cronjob is root's... it should be in root's crontab...

1 Like

Yes using root's crontab sounds good. I'll try that thank you

---------- Post updated 16-12-14 at 10:27 ---------- Previous update was 15-12-14 at 14:36 ----------

I have tried the root's crontab and it executed the command successfully; however, external disk is not waking up. Then I ran fdisk -l manually, that also didn't worked. So do you have any method that will wake up the disk everytime?

OS: Centos 6.6 64bit

You could try command cd-info to wake up the drive. It is provided by libcdio-0.81-3.1.el6

This is a proprietary WD feature and the 'proper' way to make it behave involves installing proprietary windows drivers on windows.

The usual problem on Linux is being unable to spin them down. :confused:

Before opening this thread, I have searched google for my problem and couldn't find a working solution. You are right the general problem people are having is that the external drive doesn't spin down on linux.

So I'm actually happy that my drive spins down, but why it doesn't wake up when it is necessary.

Thank you for your answers, I guess I will switch to USB flash disk.