Last active
December 17, 2015 20:39
-
-
Save mhluska/5669349 to your computer and use it in GitHub Desktop.
Unmount and spin-down a drive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DRIVE_NAME=${1:-Backup} | |
if [ -z "${DRIVE_NAME}" ]; then | |
echo 'No drive found.' 1>&2 | |
exit 1 | |
fi | |
drive_dir="$(mount -l | grep "\[${DRIVE_NAME}\]" | awk '{print $1}')" | |
drive_dir_no_num=$(echo ${drive_dir} | sed -E 's,/dev/([a-z]*).*,/dev/\1,g') | |
# Unmounts and spins down an external drive. | |
udisks --unmount ${drive_dir} | |
udisks --detach ${drive_dir_no_num} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment