Quick CLI Hack to set writecache on 3w-9xxx 9650SE on the cli

First off this hack requires you have the tw_cli tool installed. If so just modify this to suite your needs and have fun. I ran into the need for this after I noticed that the following log messages :


Jan 13 11:09:44 pbnj kernel: 3w-9xxx: scsi0: AEN: INFO (0x04:0x0055): Battery charging started:.
Jan 13 11:09:45 pbnj kernel: 3w-9xxx: scsi0: AEN: INFO (0x04:0x0056): Battery charging completed:.

would cause the write cache to get turned off. Likely a GUI way or flag to trip but I like a little CLI challenge on my lunch break ;)

WARNING: MAKE SURE YOU HAVE A BATTERY HOOKED UP AND CHARGED BEFORE DOING THIS!

Not using a battery with write cache on is dangerous…sometimes silly..and sometimes down right deadly to your data. Use with caution! I am not responsible if you use this and it harms your system in anyway!

UPDATE : A more powerful version of this code now lives at My Gitlab Page for this project . I am going to be updating there moving forward.


TWCLI=/usr/sbin/tw_cli
SYSLOG="/usr/bin/logger -t LSI"
CONTROLLER=$(tw_cli show | awk '/c./ {print $1}')
for i in $($TWCLI /$CONTROLLER show unitstatus | egrep -o 'u[0-9]'); do
    case $($TWCLI /$CONTROLLER/$i show wrcache | cut -d= -f2 | sed 's/^[ \t]*//;/^$/d') in
	on)
	$SYSLOG "WriteCache is on for /c2/$i"
	;;
	off)
	$SYSLOG "WriteCache is off for /c2/$i ..turning on"
	$TWCLI /$CONTROLLER/$i set wrcache=on quiet
	;;
	*)
	$SYSLOG "WriteCache or script is fubar please fix"
	;;
    esac
done

Leave a Reply