#
# Add, remove, mount, and unmount external SATA drives
-DEV=/dev/sdb2
+BASEDEV=/dev/sdc
+PARTITION=2
MNT=/media/esata
+SCSIDEV=3 # This can change based on OS, bus enumeration, etc.
+# ----
+DEV=${BASEDEV}${PARTITION}
DELAY=5
-SCSIDEV=1 # This can change based on OS, etc.
registered() {
- if [ -b "$DEV" ]; then
+ if [ -b "$BASEDEV" ]; then
[ -n "$VERBOSE" ] && echo "registered"
return 0
else
fi
}
+partitioned() {
+ if [ -b "$DEV" ]; then
+ [ -n "$VERBOSE" ] && echo "partitioned"
+ return 0
+ else
+ [ -n "$VERBOSE" ] && echo "not partitioned"
+ return 1
+ fi
+}
+
mounted() {
if mount | grep -q "$MNT"; then
[ -n "$VERBOSE" ] && echo "mounted"
domount() {
mounted && return 0
doregister || return 1
+ partitioned || return 1
[ -n "$VERBOSE" ] && echo "mount SATA $DEV"
mkdir -p "$MNT" || return 1
mount "$DEV" "$MNT" || return 1
fi
elif [ "$1" = "register" ]; then
if doregister; then
- echo "esata registered as $DEV"
+ echo "esata drive registered as $BASEDEV"
+ partitioned || echo "WARNING: drive is not partitioned"
else
echo "$0: cannot register esata" >&2
exit 1
if mounted; then
echo "esata mounted on $MNT"
elif registered; then
- echo "esata registered as $DEV but not mounted"
+ echo "esata registered as $BASEDEV but not mounted"
+ partitioned || echo "WARNING: drive is not partitioned"
else
echo "esata is unregistered"
fi