Last active
August 29, 2015 14:07
-
-
Save jonas8/e949a5e7f24f9af8b80f to your computer and use it in GitHub Desktop.
NTFS Read/write
This file contains hidden or 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 | |
| # description: | |
| # This script use to mount readable/writable NTFS driver | |
| usage() { | |
| echo "usage: `basename $0` m|u volume name" | |
| } | |
| if [ $# -ne 2 ]; then | |
| usage | |
| exit 1 | |
| fi | |
| case $1 in | |
| m) | |
| devinfo=$(diskutil info "$2" | awk '{if(NR==2) print}' | awk -F: '{sub(/^[[:blank:]]*/,"",$2);sub(/[[:blank:]]*$/,"",$2);print $2;}') | |
| if [[ -z $devinfo ]]; then | |
| echo "$2 can not be mount." | |
| exit 1 | |
| fi | |
| $(sudo umount "/Volumes/$2" > /dev/null 2>&1) | |
| $(sudo mkdir "/Volumes/$2") | |
| $(sudo mount -t ntfs -o nobrowse,rw $devinfo "/Volumes/$2") | |
| $(open "/Volumes/$2") | |
| ;; | |
| u) | |
| $(sudo umount "/Volumes/$2") | |
| ;; | |
| *) usage | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment