From: R. Steve McKown Date: Wed, 16 Dec 2009 17:44:34 +0000 (-0700) Subject: Merge the old svn esata repo, whose history is in the esata branch. X-Git-Tag: 0.2~4 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=ovzbpc.git;a=commitdiff_plain;h=1d5e423c190546314e20b73856af66b25b1a3d3d Merge the old svn esata repo, whose history is in the esata branch. --- diff --git a/README.esata b/README.esata new file mode 100644 index 0000000..190c085 --- /dev/null +++ b/README.esata @@ -0,0 +1,17 @@ +The Dell PE1800 servers utilize the Intel ICH8 chipset, which will not do +hot swap SATA. However, "cold plug" is supported. + +1. Connect an ESATA to SATA connector inside the DELL PE1800 from SATA CON 0 + to an external card cage bracket. KingWin makes such an adapter cheap. +2. Power up the PE1800. +3. To use the external ESATA drive: + 1. Connect the drive to the PE1800 via an ESATA cable. + 2. Power it up. + 3. Run the script: sudo esata mount. + 4. Perform the IO operations with the mounted filesystem @ /media/esata. + 5. Run the script: sudo esata umount. + 6. Power down the drive. + 7. Disconnect the drive's ESATA cable from the PE1800. + +Prerequisites: + - sudo apt-get install scsiadd diff --git a/esata b/esata new file mode 100755 index 0000000..130eb80 --- /dev/null +++ b/esata @@ -0,0 +1,110 @@ +#!/bin/bash + +DEV=/dev/sdb2 +MNT=/media/esata +DELAY=5 +SCSIDEV=1 # This can change based on OS, etc. + +registered() { + if [ -b "$DEV" ]; then + [ -n "$VERBOSE" ] && echo "registered" + return 0 + else + [ -n "$VERBOSE" ] && echo "not registered" + return 1 + fi +} + +mounted() { + if mount | grep -q "$MNT"; then + [ -n "$VERBOSE" ] && echo "mounted" + return 0 + else + [ -n "$VERBOSE" ] && echo "not mounted" + return 1 + fi +} + +doregister() { + registered && return 0 + [ -n "$VERBOSE" ] && echo "register SATA device" + scsiadd -a $SCSIDEV 0 0 0 >/dev/null || return 1 + sleep $DELAY + registered || return 1 + [ -n "$VERBOSE" ] && echo "register ok" + return 0 +} + +domount() { + mounted && return 0 + doregister || return 1 + [ -n "$VERBOSE" ] && echo "mount SATA $DEV" + mkdir -p "$MNT" || return 1 + mount "$DEV" "$MNT" || return 1 + [ -n "$VERBOSE" ] && echo "mount ok" + return 0 +} + +dounregister() { + registered || return 0 + [ -n "$VERBOSE" ] && echo "unregister SATA device" + scsiadd -r $SCSIDEV 0 0 0 >/dev/null || return 1 + sleep $DELAY + registered && return 1 + [ -n "$VERBOSE" ] && echo "unregister ok" + return 0 +} + +doumount() { + if mounted; then + [ -n "$VERBOSE" ] && echo "unmount SATA $DEV" + umount "$MNT" || return 1 + mounted && return 1 + [ -n "$VERBOSE" ] && echo "unmount ok" + fi + dounregister || return 1 + return 0 +} + +# MAIN + +unset VERBOSE +if [ "$1" = "-v" ]; then + VERBOSE=1 + shift +fi +if [ "$1" = "mount" ]; then + if domount; then + echo "esata mounted on $MNT" + else + echo "$0: cannot mount esata" >&2 + dounregister + fi +elif [ "$1" = "umount" -o "$1" = "unmount" ]; then + if doumount; then + echo "esata is unmounted" + else + echo "$0: cannot unmount esata" >&2 + exit 1 + fi +elif [ "$1" = "register" ]; then + if doregister; then + echo "esata registered as $DEV" + else + echo "$0: cannot register esata" >&2 + exit 1 + fi +elif [ "$1" = "status" ]; then + if mounted; then + echo "esata mounted on $MNT" + elif registered; then + echo "esata registered as $DEV but not mounted" + else + echo "esata is unregistered" + fi + #mount | grep "$DEV" + #scsiadd -p | grep "scsi1" +else + echo "usage: $0 [-v] " +fi +exit 0