您的位置:首页 > 运维架构 > Linux

Linux怎么挂载ntfs格式的U盘设备

2017-04-18 13:10 387 查看
查看系统是否识别到了U盘设备,一般系统都会自动识别:fdisk –f

[root@localhost ~]# fdisk -l

磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0007e736
………… \\此处省略几万字
设备 Boot Start End Blocks Id System
/dev/sdb1 * 915705 60163424 29623860 7 HPFS/NTFS/exFAT
/dev/sdb4 60178797 60629309 225256+ e W95 FAT16 (LBA)
/dev/sdb1即为外插U盘设备,格式为:ntfs,新建挂载目录
[root@localhost~]# mkdir -p /mnt/usb
挂载U盘发现未知的文件系统

[root@localhost ~]# mount -t ntfs-3g /dev/sdb1 /mnt/usb/
mount: 未知的文件系统类型“ntfs-3g”
yum一下,看centos7自带库里有没有ntfs相关格式的安装包,发现没有

[root@localhost ~]# yum install ntfs*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.zju.edu.cn
* updates: mirrors.zju.edu.cn
没有可用软件包 ntfs-3g_ntfsprogs-2013.1.13。
没有可用软件包 ntfs-3g_ntfsprogs-2013.1.13.tgz。
错误:无须任何处理
这里提供两种方法

一,centos7的yum安装,默认centos7最小安装是不带ntfs-3g安装包的,只能先升级库添加aliyun的epel源来yum安装的方式
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-7.repo
--2017-04-18 19:17:06-- http://mirrors.aliyun.com/repo/epel-7.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)...112.124.140.210, 115.28.122.210
正在连接 mirrors.aliyun.com(mirrors.aliyun.com)|112.124.140.210|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1084 (1.1K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/epel.repo”

100%[============================================>] 1,084 --.-K/s 用时 0s

2017-04-18 19:17:06 (129 MB/s) - 已保存“/etc/yum.repos.d/epel.repo” [1084/1084]) 在对yum的库安装包进行升级: yum update [root@localhost ~]# yum update
已加载插件:fastestmirror http://mirrors.aliyuncs.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14]curl#7 -
升级完成后就可以用yum安装了:yuminstall ntfs-3g

[root@localhost ~]# yum install ntfs-3g
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* epel: mirrors.aliyun.com
* extras: mirrors.zju.edu.cn
* updates: mirrors.zju.edu.cn
现在就可以正常挂载了:mount -t ntfs-3g /dev/sdb1 /mnt/usb/

[root@localhost ~]# mount -t ntfs-3g /dev/sdb1 /mnt/usb/
[root@localhost ~]# ls /mnt/usb
autorun.inf GHO System Volume Information
DG2015Setup_1031E.exe icon.ico YLMF_GHOSTWIN7SP1_X64_YN2017.ISO
DVDFab_VirtualDrive_1.5.1.1.exe ISO
二, 下载安装包自行安装 安装之前需要先安装ntfs-3g依赖的gcc,

[root@localhost ~]# yum install gcc已加载插件:fastestmirrorLoading mirror speeds from cached hostfile * base:mirrors.zju.edu.cn * extras:mirrors.zju.edu.cn * updates:mirrors.zju.edu.cn

下载命令地址:wgethttp://tuxera.com/opensource/ntfs-3g_ntfsprogs-2013.1.13.tgz
[root@localhost~]# wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2013.1.13.tgz --2017-04-18 18:17:40-- http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2013.1.13.tgz 正在解析主机 tuxera.com (tuxera.com)... 77.86.224.47
正在连接 tuxera.com (tuxera.com)|77.86.224.47|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1176304 (1.1M) [application/x-gzip]
正在保存至: “ntfs-3g_ntfsprogs-2013.1.13.tgz”

100%[===============================================>] 1,176,304 264KB/s 用时 4.7s

2017-04-18 18:17:45 (246 KB/s) - 已保存 “ntfs-3g_ntfsprogs-2013.1.13.tgz” [1176304/1176304])

[root@localhost ~]# ls
anaconda-ks.cfg test.txt text0.txt text9.txt viwsda.sh
ntfs-3g_ntfsprogs-2013.1.13.tgz text text1.txt text.txt
然后解压:tar -zxvf ntfs-3g_ntfsprogs-2013.1.13.tgz

[root@localhost~]# tar -zxvf ntfs-3g_ntfsprogs-2013.1.13.tgz ntfs-3g_ntfsprogs-2013.1.13/ntfs-3g_ntfsprogs-2013.1.13/AUTHORSntfs-3g_ntfsprogs-2013.1.13/depcompntfs-3g_ntfsprogs-2013.1.13/config.subntfs-3g_ntfsprogs-2013.1.13/READMEntfs-3g_ntfsprogs-2013.1.13/install-sh
进行解压后的目录进行安装

[root@localhost~]# cd ntfs-3g_ntfsprogs-2013.1.13[root@localhostntfs-3g_ntfsprogs-2013.1.13]# ./configurecheckingbuild system type... x86_64-unknown-linux-gnucheckinghost system type... x86_64-unknown-linux-gnucheckingtarget system type... x86_64-unknown-linux-gnuchecking fora BSD-compatible install... /usr/bin/install -ccheckingwhether build environment is sane... yeschecking fora thread-safe mkdir -p... /usr/bin/mkdir -pchecking forgawk... gawkcheckingwhether make sets $(MAKE)... yes

然后make跟 make install 进行编译执行

[root@localhostntfs-3g_ntfsprogs-2013.1.13]# makemake all-recursivemake[1]: 进入目录“/root/ntfs-3g_ntfsprogs-2013.1.13”Making all in includemake[2]: 进入目录“/root/ntfs-3g_ntfsprogs-2013.1.13/include”Making all in ntfs-3gmake[3]: 进入目录“/root/ntfs-3g_ntfsprogs-2013.1.13/include/ntfs-3g”make[3]: 对“all”无需做任何事。
[root@localhost ntfs-3g_ntfsprogs-2013.1.13]# makeinstall
Making install in include
make[1]: 进入目录“/root/ntfs-3g_ntfsprogs-2013.1.13/include”
Making install in ntfs-3g
make[2]: 进入目录“/root/ntfs-3g_ntfsprogs-2013.1.13/include/ntfs-3g”
make[3]: 进入目录“/root/ntfs-3g_ntfsprogs-2013.1.13/include/ntfs-3g”
现在就可以挂载U盘了:mount-t ntfs-3g /dev/sdb1 /mnt/usb/

[root@localhost ~]# mount -t ntfs-3g /dev/sdb1 /mnt/usb/ The disk contains an unclean file system (0, 0).
The file system wasn't safely closed on Windows. Fixing.
[root@localhost ~]# ls /mnt/usb
autorun.inf DVDFab_VirtualDrive_1.5.1.1.exe icon.ico System VolumeInformation
DG2015Setup_1031E.exe GHO ISO YLMF_GHOSTWIN7SP1_X64_YN2017.ISO
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux ntfs centos7