1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MacOSでntfs formatドライブへの書き込み

Posted at

MacでのNTFSは読み込みのみ?

昔使用していたiMacでは、NTFSの読み込みに、ntfs-3gを利用していたのだが、現在のsequoiaでは動作しないらしい。

M1 MBPを使用していたときは、そもそもNTFSのディスク(USBやSSD)を使用した記憶がなかったので、気にしていなかった。(記憶ではntfs-3g+Mounty)

M4 MBPに変えてからNTFSのSSDを利用しようとしたら、読み込めるものの書き込みができない…(泣)

ググっても、NTFS対応した製品を買って動作させたという記事、PR記事ばかり。

  • iBoysoft NTFS for Mac
  • EaseUS NTFS for Mac
  • Tuxera NTFS for Mac
    などなど

欲しいのは、そうじゃないんだ…。
製品であれば動くだろうけど、Macのアップグレードで動かなくなったり、買い直しするのもバカバカしいし…。

でもきっと方法はあるはず…。

そこで試行錯誤し、なんとか動作させることができたので、記録しておく。

必要なのはmacFuseとntfs-3g-mac

それぞれ、brewでinstallしておいてください。
この辺りが参考になるはずです。

https://zenn.dev/at_yasu/articles/how-to-use-ntfs-at-mac

でもって、スクリプトを作成したので、ntfs_mount.shとでも名前をつけて保存し、実行できるようにパーミッションを変更します。
 僕は、scriptとかbinフォルダをホーム内に作成し、そこに置いてます。
(もちろんPATHも通してください)

% chmod +x ~/bin/ntfs_mount.sh

一旦、NTFSでフォーマットされたSSDなどを差し込みます。
もちろん、読み込みは可能ですが、書き込みができません。

そこで、スクリプトを実行します。

% sudo ntfs_mount.sh
Successfully mounted /dev/disk6s1 to /Volumes/ntfs.

のように出力すればOK完了。
これで、NTFSのディスクに読み書きが可能になります。

現時点での問題点

  • 複数のNTFSディスクを使用するということがないので、考慮していません。
    最初に見つけたntfsディスクを読み書き可能に再設定します。
     mount pointを/Volumes/ntfsに固定しているので、この辺りを細工すれば複数ディスクでも動くはずです。
#!/bin/bash

# This script mounts an NTFS device to a specified mount point on macOS.
# It first unmounts the device if it is already mounted, then creates the mount point
# if it does not exist, and finally mounts the device to the mount point.
# Usage: sudo ./ntfs_mount.sh

MOUNTPOINT="/Volumes/ntfs"

# Check if the script is run with root privileges
if [ "$EUID" -ne 0 ]; then
    echo "Please run as root"
    exit 1
fi

# Check ntfs usb device
DEVICE=$(mount | grep "(ntfs, local" | awk '{print $1}')
if [ -z "$DEVICE" ]; then
    echo "No NTFS device found."
    exit 1
fi

# umount
umount $DEVICE
if [ $? -ne 0 ]; then
    echo "Failed to unmount $DEVICE."
    exit 1
fi

# make mount point
mkdir $MOUNTPOINT
if [ $? -ne 0 ]; then
    echo "Failed to create $MOUNTPOINT."
    exit 1
fi

# mount
sudo mount_ntfs -o noappledouble $DEVICE $MOUNTPOINT
if [ $? -ne 0 ]; then
    echo "Failed to mount $DEVICE to $MOUNTPOINT."
    exit 1
fi

# output success message
echo "Successfully mounted $DEVICE to $MOUNTPOINT."

以上が、スクリプトの内容です。

苦労した甲斐があった!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?