From: smckown Date: Fri, 4 Apr 2008 22:21:13 +0000 (+0000) Subject: First version of the esata script. X-Git-Url: https://oss.titaniummirror.com/gitweb?a=commitdiff_plain;h=2eb7b3e74e8e713f23a1181796e5a13c80d827bf;p=ovzbpc.git First version of the esata script. --- diff --git a/README b/README new file mode 100644 index 0000000..7b73917 --- /dev/null +++ b/README @@ -0,0 +1,15 @@ +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. + diff --git a/esata b/esata new file mode 100755 index 0000000..ba81667 --- /dev/null +++ b/esata @@ -0,0 +1,90 @@ +#!/bin/bash + +DEV=/dev/sdb +MNT=/media/esata- +DELAY=3 + +registered() { + if [ -b "$DEV" ]; then + return 0 + else + return 1 + fi +} + +mounted() { + if mount | grep -q "$MNT"; then + return 0 + else + return 1 + fi +} + +doregister() { + registered && return 0 + scsiadd -a 1 0 0 0 >/dev/null || return 1 + sleep $DELAY + registered && return 0 || return 0 +} + +domount() { + mounted && return 0 + doregister || return 1 + mkdir -p "${MNT}1" || return 1 + mount ${DEV}1 ${MNT}1 || return 1 + mkdir -p "${MNT}2" || return 1 + mount ${DEV}2 ${MNT}2 || return 1 + return 0 +} + +dounregister() { + registered || return 0 + scsiadd -r 1 0 0 0 >/dev/null || return 1 + sleep $DELAY + registered && return 1 || return 0 +} + +doumount() { + mounted || return 0 + umount ${MNT}2 || return 1 + umount ${MNT}1 || return 1 + mounted && return 1 + dounregister || return 1 + return 0 +} + +if [ "$1" = "mount" ]; then + if domount; then + echo "esata is mounted" + 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 is registered" + else + echo "$0: cannot register esata" >&2 + exit 1 + fi +elif [ "$1" = "status" ]; then + if mounted; then + echo "esata is mounted" + elif registered; then + echo "esata is registered but not mounted" + else + echo "esata is unregistered" + fi + #mount | grep "$DEV" + #scsiadd -p | grep "scsi1" +else + echo "usage: $0 [mount|umount|register|status]" +fi +exit 0