Linux – How to make a USB-docked hard drive not “disconnect” from the connected system when idle

hard drivelinuxmountusb

I have connected a WD30EZRX WD Green HDD to a Thermaltake Blacx Duet 5G USB dock (similar linked, for example) in Ubuntu 12.04. Every thing seems fine until the HDD idles, when it seems to have cause the following error:

ls: reading directory .: Input/output error

This is only remedied by unmount and remount of the drive (typically as root). I have the following line in /etc/fstab

UUID=AAF670E9F670B6E3 /media/3TB ntfs defaults,user,auto 0 0

I have noticed that it seems to migrate between /dev/sdc2 and /dev/sdd2 devices on remount.

I did copy 1TB last night without issue in 1 sitting. But after x mins of idle it has the issue again.

Any tips/suggestions on how to proceed would be appreciated. Solutions specific to the hardware are optimal, but solutions to the larger problem are also appreciated.

Edit (tried as suggested):

root@mediaserver:/media/3TB# sudo hdparm -B 255 -S 253 /dev/sdd2

/dev/sdd2:

setting Advanced Power Management level to disabled

HDIO_DRIVE_CMD failed: Input/output error

setting standby to 253 (vendor-specific)

APM_level = not supported

Seems as if that didn't help with this particular drive.

Best Answer

Many USB external docks will spin the drive down after a period of inactivity, regardless of how the OS directs the drive to be treated. The problem is that the drive appears to be disconnected from the system, when it really shouldn't be. There isn't really a workaround for that particular behavior. But, there is another way to deal with it. Running a keepalive script of some kind that does some form of write to the disk about every 20 seconds or so will force the drive to not spin down. This is why the transfer session you did worked OK, because the drive didn't have a chance to be spun down.

Related Question