在CentOS中访问Windows NTFS分区

来源:互联网 发布:h3c端口加入vlan 编辑:程序博客网 时间:2024/06/01 22:17

Windows 上的磁盘分区都是 NTFS 格式,CentOS 等 Linux 版本是不支持 NTFS 格式的。NTFS-3g 这一开源软件可实现 Linux 系统对 NTFS 的读写支持。不只是 Windows 硬盘上的 NTFS 磁盘分区,只要是连在电脑上的任一 NTFS 格式的存储空间,比如 NTFS 格式的 U 盘,都可使用 NTFS-3g 实现读写支持。

1、安装编译器,否则不能成功编译。

yum install gcc

根据提示按Y安装完成

2、安装ntfs-3g

 1)下载 ntfs-3g

    下载地址: http://download.csdn.net/detail/shayboke/9830526 

2)解压

    tar zxvf ntfs-3g_ntfsprogs-2015.3.14.tar.gz

3)进入目录

    cd ntfs-3g_ntfsprogs-2011.4.12

4)编译

    ./configure 

5)安装

    make

    make install

3、查看使用

1)显示系统磁盘信息

    fdisk -l

[root@localhost /]# fdisk -l

Disk /dev/sdb: 64.0 GB, 64023257088 bytes, 125045424 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000a99a8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048      821247      409600   83  Linux
/dev/sdb2          821248   125044735    62111744   8e  Linux LVM

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xaff05648

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *         124   976768064   488383970+   f  W95 Ext'd (LBA)
Partition 1 does not start on physical sector boundary.
/dev/sda5             126   325073226   162536550+   7  HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6       325075338   652253016   163588839+   7  HPFS/NTFS/exFAT
Partition 6 does not start on physical sector boundary.
/dev/sda7       652255128   976768064   162256468+   7  HPFS/NTFS/exFAT

4、挂载分区,下面我们把

/dev/sda5分区挂载到/mnt/ntfs/winf
/dev/sda6分区挂载到/mnt/ntfs/wine
/dev/sda7分区挂载到/mnt/ntfs/wind

[root@localhost mnt]# cd ntfs
[root@localhost ntfs]# ls
[root@localhost ntfs]# mkdir wind
[root@localhost ntfs]# mkdir wine
[root@localhost ntfs]# mkdir winf
[root@localhost ntfs]# ls

设置挂载点

[root@localhost ntfs]# mount -t ntfs-3g /dev/sda5 /mnt/ntfs/winf
[root@localhost ntfs]# mount -t ntfs-3g /dev/sda6 /mnt/ntfs/wine
[root@localhost ntfs]# mount -t ntfs-3g /dev/sda7 /mnt/ntfs/wind

分区挂载完成,现在可以进入/mnt/ntfs目录下面查看对应的文件夹,即就是你移动硬盘的分区

5、卸载挂载分区

[root@localhost ntfs]# umount /dev/sda7



6、如果想让系统开机自动挂载移动硬盘,编辑/etc/fstab

cp /etc/fstab /etc/fstabbak #更改之前先备份

vi /etc/fstab #编辑

在最后添加以下信息,以读写方式挂载磁盘

/dev/sda5 /mnt/ntfs/winf defaults 0 0
/dev/sda6 /mnt/ntfs/wine defaults 0 0

/dev/sda7 /mnt/ntfs/wind defaults 0 0

:wq!保存,退出

现在只要重启机器,会自动挂载移动硬盘  

0 0