[lug] USB drive fix

Landon Cox landon at 360vl.com
Fri Nov 21 13:39:46 MST 2008


I wanted to share a fix to something that has been driving me insane  
on an ubuntu fiesty box (but don't think it's at all limited to  
that).  This fix may be common knowledge, but, if you're like me and  
you don't know it, then it's not common, eh?

I have a 500G Maxtor USB drive as a backup drive for a Dell pizza box  
running Fiesty.   I formatted it ext2, got it mounted, ran backup data  
to it, etc.  I made a daily cron job to do backups, but every morning  
when I'd look at my cron notifications, I would discovery that the  
backup failed because the file system was read-only.

I would log in to my box, try to make a file on the backup drive and  
sure enough, couldn't because it was read only.  I'd unmount it, then  
remount it and it would be fine.  By the next morning it was read-only  
again.

I reformatted the drive to ext3, reiserfs...no matter what, I had  
problems.   Looking at log messages I would see things like this:

Nov 19 07:29:54 hurricane kernel: [724306.332761] sd 4:0:0:0: Device  
not ready: <6>: Current: sense key: Not Ready
Nov 19 07:29:54 hurricane kernel: [724306.332771]     Additional  
sense: Logical unit not ready, initializing command required
Nov 19 07:29:54 hurricane kernel: [724306.332781] end_request: I/O  
error, dev sdb, sector 10706
Nov 19 07:29:54 hurricane kernel: [724306.332785] printk: 4 messages  
suppressed.
Nov 19 07:29:54 hurricane kernel: [724306.332797] lost page write due  
to I/O error on sdb1

where sdb1 was my usb backup drive partition.   After digging I  
finally found a thread:

http://ubuntuforums.org/showthread.php?t=494673

that talked about a similar issue.  Some people saw it on NTFS, FAT32,  
etc - it has nothing to do with the format.

The problem is that some drives will spin down (I suppose to save  
energy), but that hoses up the filesystem and kernel for writing to it.

For me, the fix was similar to that suggested in the link above:

1) create a file in /etc/udev/rules.d  called 85-usb-hd-fix.rules and  
add this line to it:

BUS=="scsi", SYSFS{vendor}=="Maxtor", RUN+="/usr/bin/usbhdfix %k"

(where you modify the vendor to be appropriate)

2) in /usr/bin add a file: usbhdfix  and put this content in it:

#!/bin/bash
# http://ubuntuforums.org/showthread.php?t=494673

echo 1 > /sys/block/$1/device/scsi_disk:*/allow_restart

3) of course, chmod +x usbhdfix as appropriate for you.

After this, my backups never failed again due to the read-only issue.

Apparently a kernel fix is coming or is already there...I didn't chase  
that down.

Hope this helps someone,

Landon Cox
http://sawdust.see-do.org




More information about the LUG mailing list