Skip to content

Instantly share code, notes, and snippets.

@naingyeminn
Last active October 6, 2022 16:02
Show Gist options
  • Save naingyeminn/6951b92faae540260026cb865f84231c to your computer and use it in GitHub Desktop.
Save naingyeminn/6951b92faae540260026cb865f84231c to your computer and use it in GitHub Desktop.
NTFS-3G Mount Script for MacOS
#!/bin/bash
#---- ---- ---- ----
# Copyright (C) Naing Ye Minn <naingyeminn@gmail.com>
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#---- ---- ---- ----
# Install osxfuse and ntfs-3g via brew
# $ brew cask install osxfuse
# $ brew install ntfs-3g
# Run following in case of any issue
# $ brew link --overwrite ntfs-3g
# Install ntfsmount script
# $ curl -Lo /usr/local/bin/ntfsmount http://tiny.cc/ntfsmount
# $ chmod +x /usr/local/bin/ntfsmount
# Ref: https://github.com/osxfuse/osxfuse/wiki/NTFS-3G
#---- ---- ---- ----
for volume in "/Volumes"/*
do
volumeInfo=$(diskutil info "$volume")
volumeName=$(grep "Volume Name" <<< "$volumeInfo" | cut -d ':' -f2 | sed -e 's/^[[:space:]]*//')
volumeType=$(grep "Type (Bundle):" <<< "$volumeInfo" | cut -d ':' -f2 | tr -d ' ')
deviceNode=$(grep "Device Node:" <<< "$volumeInfo" | cut -d ':' -f2 | tr -d ' ')
if [[ $volumeType == 'ntfs' ]]; then
sudo umount "/Volumes/$volumeName"
sudo /usr/local/bin/ntfs-3g "$deviceNode" "/Volumes/$volumeName" -o local -o allow_other -o auto_xattr -o volname="$volumeName"
fi
done
@xqpmjh
Copy link

xqpmjh commented Apr 15, 2022

First 3 lines could change to:

cd /Volumes/
#for volume in "/Volumes"/*
for volume in *
......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment