Skip to content

Instantly share code, notes, and snippets.

@sar
Last active April 14, 2019 23:40
Show Gist options
  • Save sar/96eb54e1cf48bd3520b5e1246fd3c6d4 to your computer and use it in GitHub Desktop.
Save sar/96eb54e1cf48bd3520b5e1246fd3c6d4 to your computer and use it in GitHub Desktop.
Bash script to mount a drive with R/W permissions using OSX FUSE NTFS-3G layer.
#!/bin/bash
printf " ==================================== \n NTFS-3G Mounter | Author: Sarthak Malik \n Content made available as Open Source under MIT-License \n Remount a drive with R/W permissions using OSX-FUSE NTFS-3G layer. \n For usage guide: https://github.com/osxfuse/osxfuse/wiki/NTFS-3G \n ==================================== \n"
printf " ==================================== \n WARNING! READ CAREFULY: \n The specified volume will be unmounted. \n Please quit and save any applications before proceeding. Use at your own risk, no warranties or gaurantees implied of any kind. \n ==================================== \n"
printf " Script Usage: \n $ chmod +x ./script_name.sh \n $ ./script_name.sh \n ==================================== \n\n"
if [[ "$OSTYPE" == "darwin"* ]]
then
# Get volume name from user input
echo ">> Detected $OSTYPE, proceeding to request input from $USER..."
read -p '>> Specify Volume Name and press [Enter]: ' volname
echo ""
# echo -z $volname
# Cancel on null volume name
if [ -z "$volname" ]
then
echo "INFO! Invalid volume name specified, cancelling..."
else
# Unmount volume with umount
echo ">>>>>> Unmounting $volname from system. <<<<<<"
sudo umount /Volumes/$volname
echo ""
# Get UUID from diskutil
echo ">>>>>> Get Volume UUID from dislutil <<<<<<"
diskId=`diskutil info $volname | grep Node`
echo $diskId
echo ""
echo ">>>>>> Requesting mount with NTFS-3G... <<<<<<"
sudo mkdir /Volumes/$volname
# TODO: regex extract /dev/disk1s1 from output
# For now, prompt for user input
read -p '>> Specify Volume UUID (ex. /dev/disk2s2; see output above) and press [Enter]: ' volId
sudo /usr/local/bin/ntfs-3g $volId /Volumes/$volname -o local -o allow_other -o noappledouble -o noapplexattr
echo ""
printf "\n ==================================== \n INFO! Mounted unless additional output from NTFS-3G logged above. \n ==================================== \n"
fi
else
echo "WARNING! Unsupported $OSTYPE detected, terminating script..."
fi
# Supported configuration:
# Mac OS X 10.5.8 (or later)
# brew install ntfs-3g
# OSXFUSE*.dmg
# Use at your own risk!
# No gaurantees or warranties implied of any kind.
# Please share and improve this code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment