VirtualBox虚拟机安装增强功能到共享文件夹

VirtualBox很多时候如果不安装增强功能,可能画面会很少,下面是安装的步骤

  • VirtualBox版本5.1.26
  • 虚拟机系统Centos7

首先我们要下载对应的增强包下载地址下载完之后我们就需要装载与自动挂载了

VirtualBox虚拟机安装增强功能到共享文件夹_第1张图片

[root@localhost /]# mkdir cdrom
[root@localhost /]# mount -t auto /dev/cdrom ./cdrom
[root@localhost /]# cd cdrom
[root@localhost cdrom]# sh ./VBoxLinuxAdditions.run 

挂载成功后,我们就可以运行开始安装了。安装过程中遇到问题了

[root@localhost cdrom]# sh ./VBoxLinuxAdditions.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.26 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.
Failed to set up service vboxadd, please check the log file
/var/log/VBoxGuestAdditions.log for details.

按照提示,/var/log/VBoxGuestAdditions.log我们查看这个文件

[root@localhost cdrom]# cat /var/log/VBoxGuestAdditions.log

vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: modprobe vboxguest failed.

按照提示我们再查看,/var/log/vboxadd-install.log

[root@localhost cdrom]#  cat /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:112: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again。 停止。
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

大概意思就是找不到当前linux的源代码,那么我们只好更新源代码了

[root@localhost cdrom]#  uname -r
3.10.0-693.el7.x86_64
[root@localhost cdrom]# rpm -qa | grep kernel-devel
[root@localhost cdrom]# yum install -y "kernel-devel-uname-r == $(uname -r)"

更新完只好,发现还是有问题

[root@localhost cdrom]# cat /var/log/vboxadd-install.log
grep: /lib/modules/3.10.0-693.el7.x86_64/build/include/linux/version.h: 没有那个文件或目录
make KBUILD_VERBOSE=1 CONFIG_MODULE_SIG= -C /lib/modules/3.10.0-693.el7.x86_64/build SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j1 modules
arch/x86/Makefile:96: stack-protector enabled but compiler support broken
Makefile:641: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
make[1]: gcc:命令未找到
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (        \
echo >&2;                           \
echo >&2 "  ERROR: Kernel configuration is invalid.";       \
echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
echo >&2 ;                          \
/bin/false)
mkdir -p /tmp/vbox.0/.tmp_versions ; rm -f /tmp/vbox.0/.tmp_versions/*
make -f scripts/Makefile.build obj=/tmp/vbox.0
  gcc -Wp,-MD,/tmp/vbox.0/.VBoxGuest-linux.o.d  -nostdinc -isystem  -I./arch/x86/include -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -std=gnu89 -O2 -m64 -mno-mmx -mno-sse -mno-red-zone -mcmodel=kernel -maccumulate-outgoing-args -Wframe-larger-than=2048 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -Wno-declaration-after-statement -include /tmp/vbox.0/include/VBox/VBoxGuestMangling.h -fno-pie -I/lib/modules/3.10.0-693.el7.x86_64/build/include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -I/tmp/vbox.0/vboxguest/ -I/tmp/vbox.0/vboxguest/include -I/tmp/vbox.0/vboxguest/r0drv/linux -D__KERNEL__ -DMODULE -DVBOX -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_GUEST -DIN_GUEST_R0 -DIN_MODULE -DRT_WITH_VBOX -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DRT_ARCH_AMD64 -DVBOX_WITH_64_BITS_GUESTS  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(VBoxGuest_linux)"  -D"KBUILD_MODNAME=KBUILD_STR(vboxguest)" -c -o /tmp/vbox.0/.tmp_VBoxGuest-linux.o /tmp/vbox.0/VBoxGuest-linux.c
/bin/sh: gcc: 未找到命令
make[2]: *** [/tmp/vbox.0/VBoxGuest-linux.o] 错误 127
make[1]: *** [_module_/tmp/vbox.0] 错误 2
make: *** [vboxguest] 错误 2
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

这次发现是gcc没有,那么我们就安装gcc吧,这里就忽略gcc的安装了,安装完gcc后,再次安装。

[root@localhost cdrom]# sh ./VBoxLinuxAdditions.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.1.26 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 5.1.26 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Starting the VirtualBox Guest Additions.

Could not find the X.Org or XFree86 Window System, skipping.

最后显示没有找到X.org或者XFree66的桌面系统,看样子应该是成功了,尝试一下共享文件夹

VirtualBox虚拟机安装增强功能到共享文件夹_第2张图片

VirtualBox虚拟机安装增强功能到共享文件夹_第3张图片
[root@localhost /]# cd mnt
[root@localhost mnt]# mkdir share
[root@localhost mnt]# mount -t vboxsf share /mnt/share
[root@localhost mnt]# cd share
[root@localhost share]# ls
mysql-5.5.59-linux-glibc2.12-i686.tar.gz

如此一来就可以解决了

你可能感兴趣的:(Linux学习之路)