How to fix NTFS support on OSX Lion
After I upgraded my Mac to Lion this month, I’ve noticed that my NTFS drives stopped working. I’m using NTFS on my Windows XP partition and on a WD external drive. I’ve previously used MacFUSE and NTFS-3G, which is probably the most commonly used solution for people who want full NTFS access on OSX (as you probably know, by default OSX only provides read only support). However, that doesn’t work anymore on Lion. The problem is that MacFUSE is not maintained anymore and doesn’t work with a 64-bit kernel which is used by default in Lion.
First Google results usually point you to commercial solutions, but I’m not willing to pay for something as basic as filesystem support, which, frankly, Apple should have provided themselves long time ago. If you want to avoid paying, the right way is to replace latest stable MacFUSE with something that works on Lion.
Based on a few blog posts and comments I managed to find a way that worked for me, so I thought I’d put it all here in one place for others. The fastest way IMHO is to install packages from the command line, because – at least in case of NTFS-3G – it’s hard to tell from the website which version is the right one. I’m going to assume you haven’t lived under a rock for the last couple of years and you’re using Homebrew, not MacPorts. It’s not completely automatic – you’ll need to do a few things in the terminal, but it shouldn’t take more than a few minutes in total.
Instructions
So here we go:
Just to be safe, remove old MacFUSE and NTFS-3G. You can use the “Uninstall” buttons in Preferences panels, but at least for MacFUSE that didn’t work for me, so if it doesn’t, just remove the panels from Preferences. You can reboot OSX just to be sure the old stuff is gone – your NTFS partitions should mount as read only now.
Install latest Fuse4X (a fork of MacFUSE) and NTFS-3G packages:
brew install fuse4x brew install ntfs-3g
Follow the instructions in the auto-included
fuse4x-kext
package (brew info fuse4x-kext
). Basically you have to copy one file from the Homebrew package directory into/System/Library
using sudo.Follow the instructions from a blog post that explains how to make OSX use NTFS-3G when mounting drives. The post is long so just scroll to the part that says “Ok, at this point you should have a functional fuse4x and ntfs-3g install” and create an alternative
/sbin/ntfs_mount
script as described there. Two caveats:- the script needs to have a hardcoded UID of a specific user on whose behalf NTFS drives will be mounted. If you have a single user or if the user is the first one created in the system, the default values will just work.
- the script assumes MacPorts was used, so replace
/opt/local/bin/ntfs-3g
with/usr/local/bin/ntfs-3g
for Homebrew
And that’s it, you should be able to unmount drives and mount them again using Disk Utility as read-write filesystems. If it doesn’t work, try to turn it off and on again. If it still doesn’t work, see if /var/log/ntfsmnt.log
gives you any clues.
Update: it seems that OSX can overwrite the /sbin/ntfs_mount
script during a system update, so if a NTFS drive suddenly goes readonly again, it’s probably that. You can keep a backup of the script at e.g. /sbin/ntfs_mount.rw
so that you can restore it quickly if this happens.
13 comments:
N Heinrichs
Thanks for collecting this info; you made my reinstall a -lot- easier.
Nils Haldenwang
Thanks for sharing, works like a charm.
Michele De Pascalis
I edited the script so that every user except for the Guest have read/write permissions, independently from the user who mounted the filesystem. Here you go:
<pre><code>#!/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 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 \
-o fmask=0111 \
-o dmask=0000 \
-o rw \
-o auto \
-o user \
"$@" &> /var/log/ntfsmnt.log
exit $?;</code></pre>
Giacomo
Looks like ntfs-3g now provides a script under /usr/local/sbin, which you can then link from sbin:
ln -s /usr/local/sbin/mount_ntfs /sbin/mount_ntfs
Works for me.
vikred
Hey, it works! I don't know why people would want to go for paid ones if NTFS write works so effortlessly with brew.
Giuseppe
It works in Mountain Lion as well. Thanks!
XBL
hey, could you please tell me how I could reverse everything I did with the above as I couldn't make it work. And now my mac doesn't even detect my NTFS drives when I plug it in anymore. Please help! Thanks
Kuba
@XBL: if you've made a backup of the old mount script at /sbin/mount_ntfs.orig, it should be enough to just restore that script with 'sudo cp /sbin/mount_ntfs.orig /sbin/mount_ntfs' (if you didn't, you'll have to find it somewhere...).
John O'Gara
Work a treat, thanks for distilling that other blog Kuba!
Rami
The article linked in here has moved to a new URL: http://fernandofig.wordpress.com/2011/08/08/ntfs-write-support-on-osx-lion-with-ntfs-3g-f/
Kuba
Thanks!
soujirou7
It just me or is did both scripts (blog post and from Michele) have the second and third if statements spelled "fi else"? This seems like an error and I wonder if it is the reason my drives are not mounting (at all!). Will try re-writing it and if that doesn't work I'll try the provided script Giacomo mentioned.
Kuba
@soujirou7 - I think it's ok, 'fi' closes an 'if' in Bash; it would normally be: if / else / fi, but the fi actually closes a nested if inside the first one.