在M1 Mac 上安装使用 NTFS-3G

自从换了 M1 的 mac 后,发现原先可以使用的读写 NTFS 硬盘的工具不支持 M1 芯片。虽然 OS X 系统支持挂载并读取 NTFS 格式硬盘,但不支持写,于是今天(2022/4/9)抽空安装了 NTFS-3G。
如果没有使用 terminal 进行文件读写删除等操作的,本文不适合你。

NTFS-3G 简介

NTFS-3G项目主页在github,安装见此

安装前提

首先需要安装 Fuse for macOS 和 Homebrew。 Homebrew 的安装可以参考M1 Mac 安装 OpenCV 和 TensorFlow

安装 macFUSE

进入主页,在右侧下载安装包,当前最新版本是 4.2.4。dmg文件下载挂载后,点击安装,因为安装的是系统扩展,会弹出提示,要求关闭电脑,然后重新开机进入 Startup Security Utility;进入后,选择允许 signed 的 developer。如果这一步不能搞定,那么下面的就不用看了,本文不适合你。
重新开机后,打开设置,在最下放看到存在 macFUSE,则表示扩展安装成功了。

安装 NTFS-3G

按照Installation的说明,首先执行:

% brew tap gromgit/homebrew-fuse
==> Tapping gromgit/fuse
Cloning into '/opt/homebrew/Library/Taps/gromgit/homebrew-fuse'...
fatal: unable to access 'https://github.com/gromgit/homebrew-fuse/': LibreSSL SSL_read: error:02FFF03C:system library:func(4095):Operation timed out, errno 60
Error: Failure while executing; `git clone https://github.com/gromgit/homebrew-fuse /opt/homebrew/Library/Taps/gromgit/homebrew-fuse --origin=origin --template=` exited with 128.

因为某些原因,使用 https 协议 clone 时会有如上错误。可以考虑使用 git 协议:

% git clone git@github.com:gromgit/homebrew-fuse.git /opt/homebrew/Library/Taps/gromgit/homebrew-fuse --origin=origin --template=
Cloning into '/opt/homebrew/Library/Taps/gromgit/homebrew-fuse'...
remote: Enumerating objects: 1357, done.
remote: Counting objects: 100% (1014/1014), done.
remote: Compressing objects: 100% (650/650), done.
remote: Total 1357 (delta 735), reused 617 (delta 352), pack-reused 343
Receiving objects: 100% (1357/1357), 181.51 KiB | 575.00 KiB/s, done.
Resolving deltas: 100% (873/873), done.

接下来,再执行:

brew install ntfs-3g-mac

读写 NTFS 硬盘

首先连接硬盘,然后查看下挂载的情况:

% diskutil list

/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.0 TB     disk4
   1:               Windows_NTFS Seagate Backup Plus ... 1.0 TB     disk4s1

记住最后一列中的 identifier,这里是 disk4s1。 因为OS X 系统可以挂载 NTFS 系统为可读状态,需要先 unmaount 在用 ntfs-3G mount。

% sudo diskutil unmountDisk /dev/disk4
Unmount of all volumes on disk4 was successful

注意,github 上使用的是 unmount 命令。这里执行出错,然后根据提示使用 unmountDisk
接着进行挂载:

sudo mkdir /Volumes/NTFS
mount_ntfs /dev/disk4s1 /Volumes/NTFS 

注意在我的系统上(OS X 12.3.1),安装后 ntfs-3g 和 mount_ntfs 的路径和 github 上的全路径不一样,并且两个命令都已添加到 PATH 中,故直接使用。
最后查看一下情况:

% df -h
Filesystem                                 Size   Used  Avail Capacity iused      ifree %iused  Mounted on
ntfs://disk4s1/Seagate Backup Plus Drive  932Gi  881Gi   50Gi    95%       1          0  100%   /Volumes/Seagate Backup Plus Drive

挂载成功,进入该硬盘,使用 cp 成功写文件,使用 rm 成功删除文件。

另外,根据提示,可以设置开机自动挂载 NTFS 磁盘为读写模式,但会有潜在的安全风险,因此还是不建议如此操作。

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.

参考

Installation-NTFS-3G

Comments