virtualbox的扩展插件是分为宿主机和虚拟机两部分的。

宿主机

对于宿主机来说,就是需要在virtualbox软件中添加扩展包,名字类似Oracle_VM_VirtualBox_Extension_Pack-4.0.10.vbox-extpack

虚拟机

而对于虚拟机而言,如果虚拟机是window系统,那么当宿主机安装了扩展包后,虚拟机会自动下载并安装对应的子机插件。而对于Linux系统,则需要安装VBoxGuestAdditions_4.0.10.iso 插件。

首先需要在官网找到对应版本的virtualbox软件源:http://download.virtualbox.org/virtualbox/
在软件源中查找对应的addtions插件,比如VBoxGuestAdditions_4.0.10.iso

加载后mount起来,进入目录中,然后执行其中的run命令,该命令会自动安装插件,需要注意的是Linux系统需要安装kernel devel和kernel headers包,确保安装时正常。

安装完成后重启Linux虚拟机,通过systemctl status vbox*命令来确认下对应的vbox插件运行是否正常。

[root@localhost mnt]# systemctl status vbox*
● vboxadd.service
   Loaded: loaded (/opt/VBoxGuestAdditions-6.1.12/init/vboxadd; enabled; vendor preset: disabled)
   Active: active (exited) since Fri 2021-03-05 19:46:23 CST; 18min ago
  Process: 836 ExecStart=/opt/VBoxGuestAdditions-6.1.12/init/vboxadd start (code=exited, status=0/SUCCESS)
 Main PID: 836 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/vboxadd.service

Mar 05 19:46:18 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions: Starting.
Mar 05 19:46:18 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel
Mar 05 19:46:18 localhost.localdomain vboxadd[836]: modules.  This may take a while.
Mar 05 19:46:18 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions: To build modules for other installed kernels, run
Mar 05 19:46:18 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
Mar 05 19:46:18 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions: or
Mar 05 19:46:18 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
Mar 05 19:46:23 localhost.localdomain vboxadd[836]: VirtualBox Guest Additions: Running kernel modules will not be replaced until
Mar 05 19:46:23 localhost.localdomain vboxadd[836]: the system is restarted
Mar 05 19:46:23 localhost.localdomain systemd[1]: Started vboxadd.service.

● vboxadd-service.service
   Loaded: loaded (/opt/VBoxGuestAdditions-6.1.12/init/vboxadd-service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-03-05 19:46:23 CST; 18min ago
  Process: 1991 ExecStart=/opt/VBoxGuestAdditions-6.1.12/init/vboxadd-service start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/vboxadd-service.service
           └─2001 /usr/sbin/VBoxService --pidfile /var/run/vboxadd-service.sh

Mar 05 19:46:23 localhost.localdomain systemd[1]: Starting vboxadd-service.service...
Mar 05 19:46:23 localhost.localdomain vboxadd-service[1991]: vboxadd-service.sh: Starting VirtualBox Guest Addition service.
Mar 05 19:46:23 localhost.localdomain systemd[1]: Started vboxadd-service.service.

假如安装的不对,这里可以看到错误的log,并针对性的解决即可。

共享文件夹设置

安装完了扩展插件以后,可以使用共享文件夹功能。

虚拟机Linux中:

usermod -a -G vboxsf  root
mount -t vboxsf  {共享目录名}   /mnt/share
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐