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.

这个错我在网看到太多,但没有一处有详解的,现在终于可以明了了。


切记,在多内核系统,或者说系统中有相同套件的时候,一定要搞清楚自己要装的是哪个,否则当时无结果还算是小事情,像这种到最后才出问题才是浪费时间的大麻烦。



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