大家都知道Linux默认是不支持NTFS分区类型的,但是如果你的计算机是双系统的话,使Linux支持NTFS分区是不是一件很开心的事!这样就可以轻松问Windows盘上面的资料了也可以在Windows下往Linux磁盘里传资料。其实Linux是可以通过安装相应的软件实现对NTFS分区类型的支持的,下面我就介绍一下该如何实现
1,网上下载ntfs-3g_ntfsprogs软件源码包,并解压到桌面
[root@localhost Desktop]# ls
ntfs-3g_ntfsprogs-2013.1.13.tgz
[root@localhost Desktop]# tar -zxvfntfs-3g_ntfsprogs-2013.1.13.tgz -C ./
2,准备源码包的安装环境
[root@localhost ~]#yum install gc* -y……配置gcc、g++开发环境
Failed to set locale, defaulting to C
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat SubscriptionManagement. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.1.2-54.el5 set to beupdated
………………………………………..
…………………………
….
3,进入解压目录,执行配置文件
[root@localhost ntfs-3g_ntfsprogs-2013.1.13]#./configure
checking build system type...x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type...x86_64-unknown-linux-gnu
checking for a BSD-compatible install.../usr/bin/install –c
………………………………………
…………………..
…….
4,编译并安装
[root@localhost ntfs-3g_ntfsprogs-2013.1.13]#make&&make install
……………………………..
……………
5,给sda添加一个分区,并指定文件类型
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to10443.
There is nothing wrong with that, but this is largerthan 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., oldversions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOSFDISK, OS/2 FDISK)
Command (m for help): n……添加一个分区
First cylinder (4103-10443, default 4103):
Using default value 4103
Last cylinder or +size or +sizeM or +sizeK(4103-10443, default 10443): +10G……大小10G
Command(m for help): t…...指定分区类型
Partition number (1-6): 6……选择第二块逻辑分区
Hex code (type L to list codes): 7……类型号7为NTFS
Changed system type of partition 6 to 7 (HPFS/NTFS)
Command (m for help): p……查看结果
Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
DeviceBoot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2624 20972857+ 83 Linux
/dev/sda3 2625 2885 2096482+ 82 Linux swap / Solaris
/dev/sda4 2886 10443 60709635 5 Extended
/dev/sda5 2886 4102 9775521 83 Linux
/dev/sda6 4103 5319 9775521 7 HPFS/NTFS
Command (m for help):w……写入
6,格式化新的分区
[root@localhost ~]# partprobe ……重新获取分区信息
Warning: Unable to open /dev/sr0 read-write(Read-only file system). /dev/sr0 hasbeen opened read-only.
[root@localhost ~]# mkfs.ntfs /dev/sda6……用ntfs类型格式化磁盘
Failed to set locale, using default 'C'.
Cluster size has been automatically set to 4096bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
7,创建/NTFS/文件夹
[root@localhost ~]# mkdir -p /NTFS/
8,把sda6挂载到新建的NTFS下
[root@localhost ~]# mount -tntfs-3g /dev/sda6 /NTFS/ ……挂载指定文件系统为ntfs-3g否则将 不能挂载
9,查看挂载信息
[root@localhost ~]# df -lT
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda2 ext3 20315844 2713692 16553512 15% /
/dev/sda1 ext3 101086 12200 83667 13% /boot
/dev/sda6 fuseblk 9775520 49624 9725896 1% /NTFS
tmpfs tmpfs 511920 0 511920 0% /dev/shm
10,以上挂载在重启后将失效,所以需要配置sda6开机自动挂载
[root@localhost ~]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0
/dev/sda6 /NTFS ntfs-3g defaults 0 0
fstab中ntfs文件类型指定为ntfs-3g否则将不能开机自动挂载