2,985 瀏覽數

Linux 讀取 NTFS (NT File System)

不知道你有沒有發生過這一種糗事,把資料複製到自己的隨身硬碟(USB Hard Drive),當要把他拿去 Linux 下讀取,糗了原來我的隨身硬碟(USB Hard Drive) 格式是 NTFS ,在 Linux 不能用,結果要把隨身硬碟(USB Hard Drive)格式成 FAT32 再重新複製一次,才能解決不同系統的資料複製,其實 Linux 是有支援 NTFS 的系統,但是 RedHat 預設是沒有將這些 Package 放在光碟中,你有需要可以去 Linux NTFS 的官方網站去下載

  1. linux-ntfs.org http://www.linux-ntfs.org/doku.php?id=downloads
    這邊提供了 RedHat 所有版本已經編譯好了的套件,只要下載用 rpm 加入套件,系統即可掛載 NTFS 的檔案系統 (#mount -t ntfs /dev/sdb1 /mnt).只能掛載和讀取得動作不能做寫入.如果你還需要近一步的使用,請在下載下面的元件.

  2. ntfs-3g http://www.ntfs-3g.org/index.html#download
    fuse – http://fuse.sourceforge.net/
    需要這兩個套件才可以讓 Linux 有寫入 NTFS 的權限.方法很簡單下載後安裝:

    • ntfs-3:

      [root@benjr ~]# tar -zxvf ntfs-3g.tar.gz
      [root@benjr ~]# cd ntfs-3g
      [root@benjr ntfs-3g]# ./configure
      [root@benjr ntfs-3g]# make
      [root@benjr ntfs-3g]# make install
      
    • fuse:

      [root@benjr ~]# tar -zxvf fuse.tar.gz
      [root@benjr ~]# cd fuse
      [root@benjr fuse]# ./configure kernel_source
      [root@benjr fuse]# make
      [root@benjr fuse]# make install
      
    • 使用 #mount.ntfs-3g 的就可以寫入 NTFS 磁區.

  • yum
    使用環境為 CentOS 7 ,這兩個套件 ntfs-3g , fuse 也可透過 YUM 來安裝,但 YUM 預設並沒有這一些套件,所以我們需要新增 Repo 檔 (epel-release) ,或是手動編寫 /etc/yum.repos.d/epel.repo .

    [root@localhost ~]# yum install epel-release
    Loaded plugins: fastestmirror
    base                                                     | 3.6 kB     00:00     
    extras                                                   | 3.4 kB     00:00     
    nginx                                                    | 2.9 kB     00:00     
    updates                                                  | 3.4 kB     00:00     
    Loading mirror speeds from cached hostfile
     * base: centos.cs.nctu.edu.tw
     * extras: centos.cs.nctu.edu.tw
     * updates: centos.cs.nctu.edu.tw
    Resolving Dependencies
    --> Running transaction check
    ---> Package epel-release.noarch 0:7-6 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package                Arch             Version         Repository        Size
    ================================================================================
    Installing:
     epel-release           noarch           7-6             extras            14 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package
    
    Total download size: 14 k
    Installed size: 24 k
    Is this ok [y/d/N]: y
    Downloading packages:
    epel-release-7-6.noarch.rpm                                |  14 kB   00:06     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : epel-release-7-6.noarch                                      1/1 
      Verifying  : epel-release-7-6.noarch                                      1/1 
    
    Installed:
      epel-release.noarch 0:7-6                                                     
    
    Complete!
    [root@localhost ~]# cd /etc/yum.repos.d/epel.repo 
    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    
    [epel-debuginfo]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    
    [epel-source]
    name=Extra Packages for Enterprise Linux 7 - $basearch - Source
    #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
    failovermethod=priority
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    gpgcheck=1
    

    現在就可以透過 yum 來安裝 ntfs-3g , fuse .

    [root@localhost ~]# yum install ntfs-3g
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: centos.cs.nctu.edu.tw
     * epel: mirror.premi.st
     * extras: centos.cs.nctu.edu.tw
     * updates: centos.cs.nctu.edu.tw
    Resolving Dependencies
    --> Running transaction check
    ---> Package ntfs-3g.x86_64 2:2016.2.22-3.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package         Arch           Version                      Repository    Size
    ================================================================================
    Installing:
     ntfs-3g         x86_64         2:2016.2.22-3.el7            epel         297 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package
    
    Total download size: 297 k
    Installed size: 695 k
    Is this ok [y/d/N]: y
    Downloading packages:
    ntfs-3g-2016.2.22-3.el7.x86_64.rpm                         | 297 kB   00:01     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : 2:ntfs-3g-2016.2.22-3.el7.x86_64                             1/1 
      Verifying  : 2:ntfs-3g-2016.2.22-3.el7.x86_64                             1/1 
    
    Installed:
      ntfs-3g.x86_64 2:2016.2.22-3.el7                                              
    
    Complete!
    [root@localhost ~]# yum install fuse
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: centos.cs.nctu.edu.tw
     * epel: mirror.premi.st
     * extras: centos.cs.nctu.edu.tw
     * updates: centos.cs.nctu.edu.tw
    Resolving Dependencies
    --> Running transaction check
    ---> Package fuse.x86_64 0:2.9.2-6.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package         Arch              Version                Repository       Size
    ================================================================================
    Installing:
     fuse            x86_64            2.9.2-6.el7            base             84 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package
    
    Total download size: 84 k
    Installed size: 219 k
    Is this ok [y/d/N]: y
    Downloading packages:
    fuse-2.9.2-6.el7.x86_64.rpm                                |  84 kB   00:04     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : fuse-2.9.2-6.el7.x86_64                                      1/1 
      Verifying  : fuse-2.9.2-6.el7.x86_64                                      1/1 
    
    Installed:
      fuse.x86_64 0:2.9.2-6.el7                                                     
    
    Complete!
    
  • 網友的想法

    1. 自動參照通知: Linux – File | Benjr.tw

    發表迴響