歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 6.3 下用ntfs-3g掛載Windows NTFS分區

CentOS 6.3 下用ntfs-3g掛載Windows NTFS分區

日期:2017/2/28 15:32:41   编辑:Linux教程

默認情況下,CentOS 6.3不支持Widows NTFS硬盤分區讀寫,要想把NTFS格式的磁盤掛載到CentOS 6.3下面
需要安裝第三方的插件ntfs-3g,這裡我們采用編譯安裝插件。
1、安裝編譯器,否則不能成功編譯。
yum install gcc
根據提示按Y安裝完成

2、安裝ntfs-3gcd

/home #進入/home目錄,把軟件下載到此目錄
wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2011.4.12.tgz #下載
tar zxvf ntfs-3g_ntfsprogs-2011.4.12.tgz #解壓
cd ntfs-3g_ntfsprogs-2011.4.12 #進入目錄
./configure #編譯
make #安裝
make install #安裝
cd .. #返回上一級目錄
rm -r -f ntfs-3g_ntfsprogs* #刪除安裝程序包
3、查看使用
fdisk -l #顯示Widows NTFS硬盤分區信息
#####################################################################

Disk /dev/sda: 160.0 GB, 160041885696 bytes
240 heads, 63 sectors/track, 20673 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x18fd18ff

Device Boot Start End Blocks Id System
/dev/sda1 * 1 5093 38503048+ 7 HPFS/NTFS
/dev/sda2 5094 20673 117784800 f W95 Ext'd (LBA)
/dev/sda5 5094 9357 32234496 7 HPFS/NTFS
/dev/sda6 9358 13621 32235520 7 HPFS/NTFS
/dev/sda7 13622 17885 32233472 7 HPFS/NTFS
/dev/sda8 17885 17899 102400 83 Linux
/dev/sda9 17899 18731 6291456 83 Linux
/dev/sda10 18731 19009 2097152 82 Linux swap / Solaris
/dev/sda11 19009 19286 2097152 83 Linux
/dev/sda12 19287 20673 10484736 83 Linux


###################################################################
以上信息顯示的是我的Widows NTFS硬盤分區信息,總共160G,有四個NTFS分區

4、掛載分區,下面我們把
/dev/sda1分區掛載到/mnt/winC
/dev/sda5分區掛載到/mnt/winD
/dev/sda6分區掛載到/mnt/winE
/dev/sda7分區掛載到/mnt/winF

進入/mnt目錄,新建winC winD winE winF 四個掛載目錄
cd /mnt
mkdir winC winD winE winF

mount -t ntfs-3g /dev/sda1 /mnt/winC #掛載
mount -t ntfs-3g /dev/sda5 /mnt/winD
mount -t ntfs-3g /dev/sda6 /mnt/winE
mount -t ntfs-3g /dev/sda7 /mnt/winF

分區掛載完成,現在可以進入/mnt目錄下面查看對應的文件夾,即就是你移動硬盤的分區

如果想卸載,可以用下面的命令

umount /dev/sda1 #卸載
umount /dev/sda5
umount /dev/sda6
umount /dev/sda7

5、如果想讓系統開機自動掛載移動硬盤,編輯/etc/fstab文件。
cp /etc/fstab /etc/fstabbak #更改之前先備份
vi /etc/fstab #編輯

用insert命令在最後添加以下信息,以讀寫方式掛載磁盤

/dev/sda1 /mnt/winC ntfs-3g defaults 0 0
/dev/sda5 /mnt/winD ntfs-3g defaults 0 0
/dev/sda6 /mnt/winE ntfs-3g defaults 0 0
/dev/sda7 /mnt/winF ntfs-3g defaults 0 0

執行ESC命令退出。
:wq!保存,退出
現在只要重啟機器,會自動掛載移動硬盤

取消掛載問題:
umount的時候出現如下提示:
[[email protected] /]# umount /dev/sda1
umount: /mnt/upan: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))

解決方法:
[[email protected] /]# lsof -w /mnt/upan
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 31761 root cwd DIR 8,18 8192 2316326 /mnt/upan/rekfan.com_120526
[[email protected] /]#

使用 lsof -w /mnt/upan 可以看出,有個命令窗口在/mnt/upan/rekfan.com_120526目錄上,關閉這個窗口,或退出這個掛載目錄,再使用 umount 即可安全退出掛載的設備!

Copyright © Linux教程網 All Rights Reserved