CentOS 挂载硬件设备(U盘,硬盘等)

1、挂载fat或者fat32分区的U盘

如果是用VM安装的linux,在vm里挂载U盘有两个前提:

第一,主机里的service要启动:

第二,U盘是连接到虚拟机,而不是主机,需要确认这点:

2、使用fdisk命令先检查一下U盘是否已经加载

fdisk -l

设备/dev/sdb1 就是插入的U盘,FAT32分区

加载:
[root@bigdata-senior01 ~]# ll /mnt/usb
总用量 0
[root@bigdata-senior01 ~]# mount /dev/sdb1 /mnt/usb
[root@bigdata-senior01 ~]# ll /mnt/usb
总用量 760
-rwxr-xr-x 1 root root  34494 1月   2 01:22 autorun.ico
-rwxr-xr-x 1 root root    236 1月   2 01:22 autorun.inf
-rwxr-xr-x 1 root root     14 1月   2 00:50 CentOS_BuildTag
... ...
用df命令可以再检查一下:
[root@bigdata-senior01 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   17G  4.2G   13G   25% /
devtmpfs                 901M     0  901M    0% /dev
tmpfs                    912M     0  912M    0% /dev/shm
tmpfs                    912M  8.6M  904M    1% /run
tmpfs                    912M     0  912M    0% /sys/fs/cgroup
/dev/sda1               1014M  143M  872M   15% /boot
tmpfs                    183M     0  183M    0% /run/user/1004
/dev/sdb1                 15G  4.2G   11G   30% /mnt/usb
当不再使用U盘的时候,需要卸载设备
[root@bigdata-senior01 ~]# umount /dev/sdb1
[root@bigdata-senior01 ~]# ll /mnt/usb
总用量 0

2、挂载NTFS分区的U盘

2.1、安装NTFS-3G

CentOS默认情况下并不识别NTFS分区格式,需要使用一个开源的软件来支持。NTFS-3G 是一个开源的软件,可以实现 Linux、Free BSD、Mac OSX、NetBSD 和 Haiku 等操作系统中的 NTFS 读写支持。它可以安全且快速地读写 Windows 系统的 NTFS 分区,而不用担心数据丢失。

自带的yum源没有这个软件,要用第三方的软件源,这里采用阿里的epel。

[root@bigdata-senior01 ~]# cd /etc/yum.repos.d/
[root@bigdata-senior01 yum.repos.d]# wget http://mirrors.aliyun.com/repo/epel-7.repo

yum -y install ntfs-3g

安装NTFS-3G后,使用fdisk -l才能看到ntfs格式的u盘

这个U盘,是一个通用PE制作的启动U盘,被分成了两个分区,启动分区是FAT16,另外数据分区是NTFS,这里需要加载/dev/sdb1

挂载NTFS格式U盘
[root@bigdata-senior01 yum.repos.d]# ll /mnt/usb
总用量 0

[root@bigdata-senior01 yum.repos.d]# 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@bigdata-senior01 yum.repos.d]# ll /mnt/usb
总用量 0
drwxrwxrwx 1 root root 0 1月   9 09:54 backup
drwxrwxrwx 1 root root 0 1月   1 22:37 GHO
drwxrwxrwx 1 root root 0 1月   9 09:53 System Volume Information

参数-t ntfs-3g是可以省略的。CentOS7以后可以自动识别。
[root@bigdata-senior01 yum.repos.d]# umount /dev/sdb1
[root@bigdata-senior01 yum.repos.d]# ll /mnt/usb
总用量 0
[root@bigdata-senior01 yum.repos.d]# mount /dev/sdb1 /mnt/usb
[root@bigdata-senior01 yum.repos.d]# ll /mnt/usb
总用量 0
drwxrwxrwx 1 root root 0 1月   9 09:54 backup
drwxrwxrwx 1 root root 0 1月   1 22:37 GHO
drwxrwxrwx 1 root root 0 1月   9 09:53 System Volume Information

3、挂载一块新硬盘

猜你喜欢

转载自www.cnblogs.com/asker009/p/10269620.html