AS4,AS5,AS6支持NTFS格式的實現和思考

ntfs,這個怎麼說。又是一宗老早就要用到,但因爲太懶一直放着沒動的沉冤舊案。好吧。實現它。

根據現在實際應用的情況,我連着做了三個系統的對照實驗。連重裝虛擬機的時間兩天半搞定。


實現這個功能關鍵在於兩三個包:

kernel  ; kernel-devel ;kernel-headers(這個包如果有的話)


用到的軟件有兩個:

fuse 和 ntfs-3g

fuse下載 https://github.com/libfuse/libfuse/releases

ntfs-3g下載  http://www.tuxera.com/community/open-source-ntfs-3g/


其實真正起到決定性作用的是 ntfs-3g,但它需要通過fuse模塊來應用。而fuse模塊有一個特點,內核版本是2.6.14以及之後的版本本身就自帶了這個模塊,而之前的就只有自己安裝再加載了。

SO。那麼開始吧。

ntfs-3g 一律使用的是最新的 ntfs-3g_ntfsprogs-2015.3.14.tgz(現在是2016-02-24)


AS6.0  採用的內核版本是2.6.32的。所以應用起來最簡單。

#tar zxvf ntfs-3g_ntfsprogs-2015.3.14.tgz

#cd ntfs-3g_nftsprogs-2015.3.14

#./configure

#make 

#make install


OK,這就可以了。

./configure的時候很有可能會出如下錯誤:

/bin/rm: cannot remove `libtoolT': No such file or directory
You can type now 'make' to build ntfs-3g.

這個直接把./configure裏面 $RM "$cfgfile" 這行前面加#註釋掉就行了。


找個移動硬盤接上。

#fdisk -l

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        8895    71449056    7  HPFS/NTFS


然後直接用命令掛載

#mount -t ntfs-3g /dev/sdb1 /mnt

#df -h -T

文件系統                                       類型      容量     已用      可用    已用%%      掛載點
/dev/mapper/vg_as6-lv_root     ext4      18G     4.4G      12G     27%                 /
tmpfs                                            tmpfs    504M     0          504M   0%            /dev/shm
/dev/sda1                                      ext4      485M   31M      429M   7%                /boot
/dev/sdb1                                    fuseblk   69G     27G       42G   40%              /mnt

可以看到sdb1已經掛載了,但文件類型不是ntfs,而是中間模塊fusebk。

這種方式實現的掛載,可讀可寫。

取消掛載和平時的方法一樣:

#umount /mnt


AS5,我採用的版本是5.2的,內核是2.6.18,按道理內核是包含fuse模塊的,但是並沒有發現如下:

# ls /lib/modules/2.6.18-92.el5/kernel/fs/

autofs4     cramfs    ext3      gfs2     jffs2  nfs_common  udf
cachefiles  dlm       fat       hfs      lockd  nfsd        vfat
cifs        ecryptfs  freevxfs  hfsplus  msdos  nls
configfs    exportfs  fscache   jbd      nfs    squashfs


那這樣我們只有先安裝fuse了。

# tar zxvf fuse-2.7.0.tar.gz

# cd fuse-2.7.0

# ./configure

# make

# make install


然後就可以加載fuse模塊了

# modprobe fuse

這一步如果沒報錯就表示成功了,一般也不會報錯。

OK,接下來安裝ntfs-3g

# tar zxvf ntfs-3g_ntfsprogs-2015.3.14.tgz
# cd ntfs-3g_ntfsprogs-2015.3.14
# vim ./configure                    這一步上面說過了
# ./configure
# make
# make install

OK,找個硬盤。

# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/sdb: 73.1 GB, 73172091392 bytes
255 heads, 63 sectors/track, 8896 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        8895    71449056    7  HPFS/NTFS

掛載

# mount -t ntfs-3g /dev/sdb1 /mnt

# df -h -T
文件系統                                                     類型       容量      已用      可用    已用%    掛載點
/dev/mapper/VolGroup00-LogVol00     ext3        18G      3.0G     14G      18%           /
/dev/sda1                                                    ext3       99M       12M      82M      13%       /boot
tmpfs                                                          tmpfs    506M         0       506M       0%       /dev/shm
/dev/sdb1                                                 fuseblk    69G        27G      42G      40%       /mnt

OK,sdb1已經掛載成功。


最後AS4,這個從一開始就沒有之前兩個順利,爲了安裝快,我用的是最小安裝。以至於很多包都沒有裝全。

首先是fuse的安裝,這個沒得說,AS5的都沒帶這個想都不用想了。

# tar zxvf fuse-2.7.0.tar.gz
# cd fuse-2.7.0
# ./configure

結果出錯了

configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

不用說看樣子就知道是gcc沒裝

# rpm -aq | grep gcc
libgcc-3.4.6-3

果然只裝了一個包。

gcc的關聯包有幾個,我就不扯了,下面一個個裝過來。

# rpm -ivh glibc-kernheaders-2.4-9.1.98.EL.i386.rpm

# rpm -ivh glibc-headers-2.3.4-2.25.i386.rpm

# rpm -ivh glibc-devel-2.3.4-2.25.i386.rpm

# rpm -ivh cpp-3.4.6-3.i386.rpm

# rpm -ivh gcc-3.4.6-3.i386.rpm

好了。再回去裝fuse

# ./configure

這會錯誤變了

configure: error:
        *** Please specify the location of the kernel source with
        *** the '--with-kernel=SRCDIR' option
configure: error: ./configure failed for kernel

好吧這裏的意思就是kernel的devel包沒裝上,記住一定是沒裝上,就算你裝了,系統還要你--with-kernel那也是你一定裝錯了!!!這個最後有總結說明

這個時候首先要做的是查清自己正在用的是哪個內核,如:

# uname -r
2.6.9-42.ELsmp                //這個也是AS4默認的啓動內核

# rpm -ivh kernel-smp-devel-2.6.9-42.EL.i686.rpm

再回去裝fuse

# ./configure

# make

# make install

這次就很順利了。

而生成fuse模塊的路徑是:

/lib/modules/2.6.9-42.ELsmp/kernel/fs/fuse/fuse.ko

# modprobe fuse

OK,成功。如果是本地服務器上操作還會出現fuse的版本信息。

安裝ntfs-3g

# tar zxvf ntfs-3g_ntfsprogs-2015.3.14.tgz
# cd ntfs-3g_ntfsprogs-2015.3.14
# vi ./configure
# ./configure
# make
# make install

現在可以接硬盤測試了

# fdisk -l

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/sdb: 73.1 GB, 73172091392 bytes
255 heads, 63 sectors/track, 8896 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        8895    71449056    7  HPFS/NTFS

# mount -t ntfs-3g /dev/sdb1 /mnt

# df -h -T
Filesystem           Type         容量     已用    可用   已用%    掛載點
/dev/mapper/VolGroup00-LogVol00       ext3         18G      1.1G   16G     7%         /
/dev/sda1            ext3          99M     13M     82M   14%        /boot
none                tmpfs      506M       0      506M    0%       /dev/shm
/dev/sdb1                                                     fuseblk     69G     27G     42G     40%     /mnt

OK已經掛載成功。


總結:

最後說一下最關鍵的地方,其實就是最開始那三個包。

kernel  這個是內核

kernel-devel  devel裏一般都是附加的編譯功能要用的包

kernel-headers 這個是頭文件包,但AS4各版系統盤裏都沒看到。

前兩個包是關鍵,在如AS4這種多內核系統,一定要看好自己現在正在用的是哪個內核,如果裝錯devel包,那麼生成的模塊無論切換到哪個內核都沒辦法正確加載

比如之前出現"--with-kernel=SRCDIR"錯誤的時候,我正在使用的內核是2.6.9-42.ELsmp,如果裝錯2.6.9-42.EL的devel後果就會如下:

# rpm -ivh kernel-devel-2.6.9-42.EL.i686.rpm

# ./configure --with-kernel=/usr/src/kernels/2.6.9-42.EL-i686/      //因爲裝錯包,所以還是必須用--with-kernel來指定編譯要用的文件目錄

# make

# make install

雖然最後fuse模塊也能生成,但最終的路徑卻是:

/lib/modules/2.6.9-42.EL/kernel/fs/fuse/fuse.ko

這個時候掛載是永遠不會成功一直報如下的錯:

# modprobe fuse
FATAL: Module fuse not found.

這個錯我在網看到太多,但沒有一處有詳解的,現在終於可以明瞭了。


切記,在多內核系統,或者說系統中有相同套件的時候,一定要搞清楚自己要裝的是哪個,否則當時無結果還算是小事情,像這種到最後纔出問題纔是浪費時間的大麻煩。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章