分为以下几个步骤:linux
1、设置本地yum,安装gcc(若是本机已经安装gcc,则跳过此步)安全
[local]url
name=localspa
baseurl=file:///isoblog
gpgcheck=0ip
enabled=1get
7. 本地yum配置完成,执行yum install gcc进行安装虚拟机
2、编译安装ntfs-3g驱动it
驱动下载地址:https://files.cnblogs.com/files/niceboy/ntfs-3g_ntfsprogs-2016.2.22.zipio
驱动安装完成。
3、挂载移动赢硬盘
fdisk -l 输出内容以下:
磁盘 /dev/sdb:2000.4 GB, 2000398934016 字节,3907029168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x00000000
设备 Boot Start End Blocks Id System
/dev/sdb1 1 4294967295 2147483647+ ee GPT
fdisk -l不显示硬盘的格式,可经过parted -l 查看未挂载的硬盘的格式
由于在windwos上移动硬盘未安全退出或者磁盘有问题,致使fdisk -l内容显示不全
经过parted -l查看,内容以下,显示移动硬盘应该是三个分区,可是fdisk -l只显示了第一个分区
Model: ATA ST2000DL001-9VT1 (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name 标志
1 1049kB 106MB 105MB fat32 EFI system partition 启动
2 106MB 240MB 134MB Microsoft reserved partition msftres
3 240MB 2000GB 2000GB ntfs Basic data partition
因此最后执行挂载的命令为:mount -t ntfs-3g /dev/sdb3 /usb_extdisk/
使用mount命令只能临时挂载,重启后会失效,要想下次重启自动挂载,能够经过如下方法
[root@localhost yum.repos.d]# echo "mount /dev/cdrom /iso" >> /etc/rc.local
[root@localhost yum.repos.d]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
mount /dev/cdrom /iso
或
经过修改fstab文件,支持开机自动挂载
修改/etc/fstab文件,文件最后加入:
/dev/sdc1 /usb_extdisk ntfs-3g defaults 0 0
到此并无彻底结束,若是你想随时插上U盘,移动硬盘就能够自动挂载,就好像Windows下使用那样的效果。那么就接着看吧。
在/sbin目录下新建一个脚本 vi /sbin/mount.ntfs
#!/bin/sh
export LANG=Zh_CN.UTF-8
exec /sbin/mount.ntfs-3g $@
保存退出,而且给脚本添加一个可执行权限
chmod a+x /sbin/mount.ntfs
而后你再自动插拔你的移动硬盘就能够了。