2011
12.17

A coworker of mine was asking how to get NTFS working for OSX (WTF Apple no native NTFS read/write, really? REALLY?!?). So, I shot him this link. I figured it would be a bit easier to summarize the post below:


$ brew install fuse4x
$ brew install ntfs-3g

$ sudo brew link ntfs-3g

$ sudo cp -rfX /usr/local/Cellar/fuse4x-kext/0.8.13/Library/ \
  Extensions/fuse4x.kext /System/Library/Extensions

$ sudo chmod +s /System/Library/Extensions/fuse4x.kext/Support/load_fuse4x

$ sudo mv /sbin/mount_ntfs /sbin/mount_ntfs.orig
$ sudo touch /sbin/mount_ntfs
$ sudo chmod 0755 /sbin/mount_ntfs
$ sudo chown 0:0 /sbin/mount_ntfs

$ cat < < EOF | sudo tee /sbin/mount_ntfs
#!/bin/bash
VOLUME_NAME="${@:$#}"
VOLUME_NAME=${VOLUME_NAME#/Volumes/}
USER_ID=501
GROUP_ID=20
TIMEOUT=20
if [ `/usr/bin/stat -f "%u" /dev/console` -eq 0 ]; then
        USERNAME=`/usr/bin/defaults read /library/preferences/com.apple.loginwindow | /usr/bin/grep autoLoginUser | /usr/bin/awk '{ print $3 }' | /usr/bin/sed 's/;//'`
        if [ "$USERNAME" = "" ]; then
                until [ `stat -f "%u" /dev/console` -ne 0 ] || [ $TIMEOUT -eq 0 ]; do
                        sleep 1
                        let TIMEOUT--
                done
                if [ $TIMEOUT -ne 0 ]; then
                        USER_ID=`/usr/bin/stat -f "%u" /dev/console`
                        GROUP_ID=`/usr/bin/stat -f "%g" /dev/console`
                fi
        else
                USER_ID=`/usr/bin/id -u $USERNAME`
                GROUP_ID=`/usr/bin/id -g $USERNAME`
        fi
else
        USER_ID=`/usr/bin/stat -f "%u" /dev/console`
        GROUP_ID=`/usr/bin/stat -f "%g" /dev/console`
fi
/usr/local/bin/ntfs-3g \
        -o volname="${VOLUME_NAME}" \
        -o local \
        -o noappledouble \
        -o negative_vncache \
        -o auto_xattr \
        -o auto_cache \
        -o noatime \
        -o windows_names \
        -o user_xattr \
        -o inherit \
        -o uid=$USER_ID \
        -o gid=$GROUP_ID \
        -o allow_other \
        "$@" &> /var/log/ntfsmnt.log
exit $?;
EOF

Thanks Apples & Rubies!

*NOTE* Here is a copy of the raw file in case the formatting jacked up the ability to copy and paste. Eventually Ill look into styling my gist’s to match the layout of the blog.