Skip to content

Commit

Permalink
Create script and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
apgsn committed Feb 12, 2022
0 parents commit c843bfb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Script automating NTFS volumes mount in read-write mode for MacOS via MacFUSE and NTFS-3G. Reference: https://github.com/osxfuse/osxfuse/wiki/NTFS-3G

Before running this script, make sure to install the following packages via Homebrew:
```bash
brew install --cask macfuse
brew install ntfs-3g-mac
```

Script execution:
```bash
./ntfs-mount.sh "My Volume Name"
```
41 changes: 41 additions & 0 deletions ntfs-mount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set -e

# Find volume info
if [[ $# -eq 0 ]]
then
echo "Please provide a volume name as an argument."
exit 1
fi

echo "Collecting information on '$1'..."

info=$(diskutil info "$1")
find_value () {
echo "$info" | grep "$1:" | awk '{ print $NF }'
}

id=$(find_value "Device Identifier")
mounted=$(find_value "Mounted")
type=$(find_value "File System Personality")

if [[ "$type" != "NTFS" ]]
then
echo "Cannot mount volume because it's not of type NTFS."
exit 1
fi

echo -e "Found id '$id' for volume '$1', mounting..."

# Unmount if necessary
if [[ "$mounted" == "Yes" ]]
then
sudo diskutil unmount /dev/$id > /dev/null
fi

# Mount volume
sudo mkdir -p /Volumes/NTFS
sudo /usr/local/bin/ntfs-3g /dev/$id /Volumes/NTFS -o local,allow_other,auto_xattr,auto_cache

echo "Volume successfully mounted."

0 comments on commit c843bfb

Please sign in to comment.