Mac下如何不借助第三方工具實現NTFS分區的可寫掛載


問題背景

我想很多使用Mac的同學都會遇到讀寫NTFS磁盤的問題,因為默認情況下Mac OSX對NTFS磁盤的掛載方式是只讀(read-only)的,因此把一個NTFS格式的磁盤插入到Mac上,是只能讀不能寫的,用起來很是不便。

因此也就出現了一些第三方工具,例如Tuxera NTFS for Mac、Paragon NTFS for MAC等,這些工具都可以實現Mac下NTFS的寫操作,但是這些工具都是收費的,當然也有些破解的版本,但是破解軟件畢竟存在安全風險,so,I don't really like that.

此外Tuxera也提供了開源的NTFS讀寫方案:NTFS-3G,基於GPL授權的NTFS-3G也可以通過用戶空間文件系統在Mac OS X上實現NTFS分區的讀寫。這個方案也比較不錯,只是需要簡單的安裝,本文不再展開。具體的可以參考官方鏈接:http://www.tuxera.com/community/open-source-ntfs-3g/

但其實,我們完全可以不借助任何第三方工具就能解決這個問題,因為其實OSX原生就是支持NTFS的。后來由於微軟的限制,蘋果把這個功能給屏蔽了,但是我們可以通過命令行手動打開這個選項。

 

How to do that?

mount查看磁盤掛載情況

1
2
3
thatsitdeMacBook-Pro:~ thatsit$  mount
/dev/disk4s2  on /Volumes/Untitled (ntfs, local, nodev, nosuid, read-only, noowners)
thatsitdeMacBook-Pro:~ thatsit$

 

這時候如果我們要實現/dev/disk4s1分區的可寫掛載,我們只需要做做一下兩個步驟:卸載、重新掛載

卸載

1
thatsitdeMacBook-Pro:~ thatsit$  sudo  umount /Volumes/Untitled/

重新掛載

1
thatsitdeMacBook-Pro:~ thatsit$  sudo  mount -t ntfs -o rw,auto,nobrowse /dev/disk4s2 /Volumes/Udisk/

  

這時候/dev/disk4s2已經以讀寫的方式掛載到/Volumes/Udisk/了,下面我們來進行掛載結果的確認

確認掛載

1
2
3
thatsitdeMacBook-Pro:~ thatsit$  mount | grep  ntfs
/dev/disk4s2  on /Volumes/Udisk (ntfs, local, noowners, nobrowse)
thatsitdeMacBook-Pro:~ thatsit$

測試寫入

1
2
3
4
5
6
7
8
9
10
11
12
thatsitdeMacBook-Pro:~ thatsit$  cd  /Volumes/Udisk/
thatsitdeMacBook-Pro:Udisk thatsit$  touch  test_writing
thatsitdeMacBook-Pro:Udisk thatsit$ ll| grep  test_writing 
-rwxr-xr-x 1 thatsit staff 0 12 24 17:14 test_writing
thatsitdeMacBook-Pro:Udisk thatsit$ 
thatsitdeMacBook-Pro:Udisk thatsit$  echo  heheda >> test_writing 
thatsitdeMacBook-Pro:Udisk thatsit$  cat  test_writing 
heheda
thatsitdeMacBook-Pro:Udisk thatsit$ 
thatsitdeMacBook-Pro:Udisk thatsit$ ll| grep  test_writing 
-rwxr-xr-x 1 thatsit staff 7 12 24 17:15 test_writing
thatsitdeMacBook-Pro:Udisk thatsit$

上述掛載參數的詳細說明:

1
2
3
4
5
6
7
8
9
10
11
12
13
<strong> mount  -t ntfs -o rw,auto,nobrowse /dev/disk4s2 /Volumes/Udisk/</strong>
 
-t ntfs  # 執行要掛載的分區文件系統格式
-o  # 執行掛載的選項
rw  # read-write,以讀寫的方式掛載
auto  # 自動檢測文件系統,此參數可以省略
nobrowse  # 這個選項非常重要,因為這選項指明了在finder里不顯示這個分區,只有打開了這個選項才能將磁盤以讀寫的方式進行掛載
/dev/disk4s2  # 要掛載的分區,也就是我們在mount命令中看到的盤符
/Volumes/Udisk/  # 掛載點
 
*  /Volumes/Udisk 這個目錄是需要存在的,如果不存在需要手動創建下: sudo  mkdir /Volumes/Udisk
* 如果目錄不存在會收到如下報錯:
mount : realpath  /Volumes/Udisk : No such  file  or directory

  

通過上面的測試大家也看到了,此時的NTFS分區已經是可寫的了;但是這個時候還存在另一個小問題,因為我們在掛載的時候使用nobrowse選項,這個分區在finder里是不顯示的。

總會有些同學不習慣一直使用命令行進行操作,所以需要高解決這個問題:
解決辦法其實很簡單,因為這個分區是掛/Volumes下的,我們把這個目錄在桌面做一個軟鏈接就OK了。

創建軟鏈接

1
2
3
thatsitdeMacBook-Pro:Udisk thatsit$  sudo  ln -s /Volumes/Udisk/ ~/Desktop/Udisk
Password:  # <----輸入用戶密碼
thatsitdeMacBook-Pro:Udisk thatsit$

效果如下:桌面上會顯示如下的盤符,點擊即可進入Finder

 

或者參考下面:

 

其實最早在OSX 10.5的時候,OSX其實原生就支持直接寫入NTFS的盤的,后來由於微軟的限制,把這個功能給屏蔽了,我們可以通過命令行手動打開這個選項。
第一步,當然是插上磁盤。(如果是BOOTCAMP,直接開始使用命令)

請別忘記,是在打開“實用工具”-“終端“里面進行輸入命令。


可以從finder或者使用以下命令查看到磁盤的Volume Name:

diskutil list

/dev/disk0 (internal, physical):
   #:                       TYPE           NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *121.3 GB   disk0
   1:                        EFI              EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS       Macintosh HD            88.0 GB    disk0s2
   3:                 Apple_Boot        Recovery HD             650.0 MB   disk0s3

   4:       Microsoft Basic Data   BOOTCAMP                32.5 GB    disk0s4



可以看到,我的 Volume Name 是BOOTCAMP。


緊接着更新 /etc/fstab文件

sudo nano /etc/fstab



出現讓你輸入自己電腦的密碼(沒有密碼的會跳過去),輸入電腦密碼后出現以下內容:

  GNU nano 2.0.6              File: /etc/fstab                                 






                                [ Read 1 line ]
^G Get Help  ^O WriteOut  ^R Read File ^Y Prev Page ^K Cut Text  ^C Cur Pos

^X Exit      ^J Justify   ^W Where Is  ^V Next Page ^U UnCut Text^T To Spell






接着把以下內容寫入進去

LABEL=BOOTCAMP none ntfs rw,auto,nobrowse


下面來依次解釋一下,如果你的名字里面有空格鍵,就需要用\040的意思是代替空格鍵,如:BOOT/040CAMP。

后面的Ntfs rw表示把這個分區掛載為可讀寫的ntfs格式,最后nobrowse非常重要,因為這個代表了在finder里不顯示這個分區,這個選項非常重要,如果不打開的話掛載是不會成功的。

完成這里以后不是按回車,按 Ctrl + X
會出現要不要保存的字樣,請按 Y 然后回車
這個時候可以重啟了。

當然還有個缺陷需要去掉:因為這個分區在finder里不顯示了,那么我們要怎么找到它呢,總不能一直用命令行。

解決辦法其實很簡單,因為這個BOOTCAMP分區是掛/Volumes下的,我們把這個目錄在桌面做一個快捷方式就行了。

sudo ln -s /Volumes/BOOTCAMP ~/Desktop/BOOTCAMP
 
抱歉一下,由於在Desktop/后面多輸入個volumes,請最后一步沒法能創建快捷方式的同學,用這個上面最新的公式。
 
如果想以后都能看到除BOOTCAMP以外其他隱藏的驅動器的話,可以多創建一個這個文件夾快捷方式:如下:
sudo ln -s /Volumes ~/Desktop/Volumes



然后我們能在桌面找到,

<ignore_js_op>

或者這個<ignore_js_op>





點開以后就能找到磁盤了,當然我們還可以把它拉到finder里面的側欄上去,就更方便了。
<ignore_js_op>



用這種方法打開的是系統原生的ntfs功能,穩定實用,比第三方工具要好用的多了。

 

 

----Done----

參考鏈接:
https://zh.wikipedia.org/wiki/NTFS


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM