Skip to content

Instantly share code, notes, and snippets.

@rdp
Created October 5, 2018 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdp/37294728ddd499c61d923cfbf3966727 to your computer and use it in GitHub Desktop.
Save rdp/37294728ddd499c61d923cfbf3966727 to your computer and use it in GitHub Desktop.

NTFS-3G

NTFS-3G is an open source cross-platform implementation of the Microsoft Windows NTFS file system with read-write support.

Please note that NTFS-3G and FUSE for macOS are independent projects. Should you run into NTFS-3G related issues please post the issues on the NTFS-3G support forum at http://tuxera.com/forum/viewforum.php?f=7.

Installation

The following instructions assume that you know how to use Terminal. Doing this the wrong way could damage your operating system.

First, download and install the latest release of FUSE for macOS from http://osxfuse.github.io. You will need at least version 3.0.

Then, if you don't have it yet, install the package manager "Homebrew" as described on https://brew.sh.

Install NTFS-3G from Homebrew by opening a Terminal and entering the following command.

brew install ntfs-3g

After installing NTFS-3G you can manually mount NTFS volumes in read-write mode by executing the following commands in Terminal. Replace /dev/disk1s1 with the actual NTFS partition you want to mount. You can find the partition name using diskutil list.

sudo mkdir /Volumes/NTFS
sudo /usr/local/bin/ntfs-3g /dev/disk1s1 /Volumes/NTFS -olocal -oallow_other

Auto-mount NTFS volumes in read-write mode

Even though you have installed NTFS-3G, newly connected NTFS volumes will still be auto-mounted in read-only mode. To change this you need to replace Apple's NTFS mount tool /sbin/mount_ntfs with the one provided by NTFS-3G.

It is important that you understand the security implications of what you are about to do. The mount tool is executed with root permissions. This means that NTFS-3G's mount tool will be executed with root permissions, too. Due to the way Homebrew installs software packages, NTFS-3G's mount tool is not protected from being tampered with by unprivileged attackers, essentially giving those attackers root access to your Mac. This is a major security risk. You have been warned.


Note:

On OS X El Capitan files in the /sbin directory are protected from being tampered with by a new security feature called System Integrity Protection (SIP). SIP does not protect you against the security threat outlined above.

To replace /sbin/mount_ntfs with the version provided by NTFS-3G you will need to reboot your Mac in recovery mode before proceeding. See https://support.apple.com/en-us/HT201314 for details on how to start the recovery system.

Once in recovery mode open a new Terminal window from the Utilities menu.


To replace Apple's NTFS mount tool with the one provided by NTFS-3G execute the following commands in Terminal. This will back up the original mount tool to /Volumes/Macintosh HD/sbin/mount_ntfs.orig.

sudo mv "/Volumes/Macintosh HD/sbin/mount_ntfs" "/Volumes/Macintosh HD/sbin/mount_ntfs.orig"
sudo ln -s /usr/local/sbin/mount_ntfs "/Volumes/Macintosh HD/sbin/mount_ntfs"

Uninstallation

To uninstall NTFS-3G, open a Terminal prompt and enter the following:

brew uninstall ntfs-3g

If you have replaced Apple's NTFS mount tool /sbin/mount_ntfs with the one provided by NTFS-3G to auto-mount NTFS volumes in read-write mode you will need to restore the original mount tool.


Note:

On OS X El Capitan files in the /sbin directory are protected from being tampered with by a new security feature called System Integrity Protection (SIP). You will need to reboot your Mac in recovery mode before proceeding. See above for details.

Once in recovery mode open a new Terminal window from the Utilities menu.


To restore Apple's NTFS mount tool execute the following command in Terminal.

sudo mv "/Volumes/Macintosh HD/sbin/mount_ntfs.orig" "/Volumes/Macintosh HD/sbin/mount_ntfs"

Frequently Asked Questions

1. Why is NTFS-3G's write performance so poor?

The ntfs-3g program opens and does I/O to the block device /dev/disk[number] of the NTFS volume in question. macOS does not have a VM buffer cache for block devices when they are accessed in this way. That is the most overwhelming factor, because both metadata operations and file data I/O boil down to read-writes by NTFS-3G to the block device.

Suppose we somehow automagically provided unified buffer caching for block devices by essentially making a disk look like a giant file. Even then, macOS and its buffer cache is really happy only when you do I/O that is in units of page size (4KB) and aligned on a page boundary. To get the most out of the I/O subsystem in macOS, ntfs-3g (or any other program for that matter) would really want to do I/O in multiples of 4KB.

For comparison, you should try writing to an NTFS disk image. You will see that it is considerably faster because you do have some caching in that case.

2. After installing NTFS-3G, my Boot Camp volume stopped showing up in the "Startup Disk" preference pane. Is reinstalling macOS, Boot Camp, and Windows the only recourse?

Relax. The "Startup Disk" preference pane is simply filtering out (that is, not displaying) any mounted volumes that it does not consider bootable. Its definition of a Boot Camp volume includes that the mounted volume either be of type msdos or ntfs - this is hardcoded into the preference pane plugin. This does not mean your Boot Camp volume has become unbootable. It is merely not showing up in the graphical user interface. You can hold the "opt" key during startup and choose the Windows partition to boot from. You can also remount it (read-only) using the NTFS file system built into macOS and it should start showing up in "Startup Disk".

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