Ubuntu Fiesty Spazzing and Returning to Read-Only State

By Landon Cox on Tuesday, December 30th, 2008 in Technical | Related Software Packages: | Keywords: ,

Issue

We’d like to share a fix for something that has been driving us insane on an Ubuntu Fiesty box (though don’t think it’s at all limited to that distro). This fix may be common knowledge, but, if, like us, you’ve not heard about it, seriously, how common can it be, eh?

The box in question is a 500G Maxtor USB drive used as a backup drive for a Dell pizza box running Ubuntu Fiesty. We formatted it ext2, got it mounted, ran backup data to it, no problems. We made a daily cron job to do backups, but every morning when we reviewed the cron notifications, we’d discover that the backup failed because the file system was read-only which is not how we left it.

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

We reformatted the drive to ext3, reiserfs…no matter what: problems. Looking at log messages we’d see things like this:

Nov 19 07:29:54 hurricane kernel: [724306.332761] sd 4:0:0:0: Device not ready: : 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, we 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 drive format as far as we can tell.

Trick

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

For us, 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, our backups never failed again due to the read-only issue.

Apparently a kernel fix is coming or is already there…we didn’t chase that down.

Landon Cox

Landon has long been a champion of our missions and a favorite here at OpenLogic and we're thrilled to have him contributing his insight and brilliance here on Wazi. See a picture of his twenty-year old oscilloscope here: http://sawdust.see-do.org.

Leave a Reply

© 2010 OpenLogic, Inc. | Licensing | Privacy Policy | Terms of Use