Gareth and Gareth have explained how to do a firmware update which (as it works for me) is a better solution:
See https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.20/+bug/75295
My own solution below is buggy and prone to calling the atapi reset TWICE (hanging the machine). I have a fix (not with me as I edit this now) which prevents the atapi reset being called twice in one minute, but I think the better solution is the firmware update.
As a consequence if the moon shakes a bit too much or one of the electrons gets a bit too hot, the CDROM drive stops responding. For windows users it disappears from My Computer altogether and they have to reboot.
Linux users are both better and worse off. Worse because the system hangs 4 seconds out of 5 and the syslog fills up with messages like "/dev/hdc: status timeout: status=0xd0 { Busy }"
If you can bear to slowly get a command window, a bit of "sudo hdparm -w /dev/hdc" will fix it, but thats too painful.
So, this script will fix it. You need to modify /etc/syslog.conf to add this line "kern.* /var/log/kern.fifo" to log kernel messages to a named pipe from which the script will read.
Install the script in /usr/local/sbin/fixhdc, and run it from /etc/rc.local with: "setsid /usr/local/sbin/fixhdc &"
#! /bin/bash
# /usr/local/sbin/fixhdc
# by Sam Liddicott
# Monitor kernel messages to see if the cdrom is jiggered
# If so do an atapi reset
# First add this line to /etc/syslog.conf
# kern.* /var/log/kern.fifo
# Then run this script from /etc/rc.local with:
# setsid /usr/local/sbin/fixhdc &
KERNFIFO=/var/log/kern.fifo
CDROM=hdc
CDROM_NODE="/dev/$CDROM"
daemon() {
while read logline
do
case "$logline" in
*"$CDROM: status timeout: status=0xd0 { Busy }"*)
hdparm -w "$CDROM_NODE"
logger -t ‘kern.crit’ — "$0 reset $CDROM"
;;
*) echo "Ignore $logline";;
esac
done
}
while :
do
if test -p "$KERNFIFO" || mkfifo "$KERNFIFO"
then daemon < "$KERNFIFO" &
# restart syslog now we have the pipe open
/etc/init.d/sysklogd reload
# it probably won’t finish till syslog does
wait
logger — "Restarting $0"
else echo "Can’t make fifo $KERNFIFO"
exit 1
fi
done
Very smart idea. I was searching for something similar to solve this problem because I don’t have any programming/scripting skill. Thank you
ReplyDelete