操作步骤
- 配置yum源
1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之后运行yum makecache生成缓存
版本查看
-
安装kernel-devel
挂载
VBoxGuestAdditions.iso
到虚拟机
该iso文件在virtualbox安装目录下可以找到,或自行从网上下载均可
- 安装VBoxGuestAdditions工具
可能遇到问题
yum install -y bzip2
bzip2 not found. Please install: bzip2 tar; and try again.
yum install -y gcc kernel-devel-3.10.0-957.el7.x86_64
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
kernel-devel kernel-devel-3.10.0-957.el7.x86_64
-
测试效果
重启虚拟机后即可看到共享目录挂载成功。
通过软连接方式将自动挂载的/media/sf_test
连接到其他目录
ln -s /media/sf_test ~/test
扩展:如果想将目录挂载到虚拟机 ~/test
[root@test sf_test]# mkdir ~/test [root@test sf_test]# [root@test sf_test]# mount -t vboxsf test ~/test/ [root@test sf_test]# [root@test sf_test]# cd ~/test/ [root@test test]# [root@test test]# echo "hello" > index [root@test test]# [root@test test]# ll total 4 -rw-r--r--. 1 root root 6 Apr 20 22:15 index # 取消挂载 [root@test test]# unmount -f ~/test