当前位置: 首页>>技术问答>>正文


如何将Guest Additions安装到VirtualBox VM中?

, ,

问题描述

我最近在Oracle的Virtualbox上安装了Ubuntu。现在我想安装客人补充。

我启动了我的Ubuntu客户操作系统,单击”Devices”并选择“安装客户添加”。什么都没有发生,我在桌面上看不到CD图标。

我该如何做这项工作?

最佳解决方案

If you have trouble installing Ubuntu in a VirtualBox VM, because the installer window does not fit the low resolution screen size, you can move the window with Alt+F7.

从存储库安装来宾添加

如果我们从存储库安装了Virtual Box的OSE版本,我们可以在guest虚拟机中添加在VirtualBox中,屏幕分辨率更高?。这将安装与从存储库获得的Virtual Box版本匹配的guest虚拟机添加。不建议将它们安装在从Oracle存储库获取的Virtual Box的新版本中(请参阅下文)。

或者,我们可以在主机Ubuntu中安装软件包virtualbox-guest-additions-iso。

sudo apt-get install virtualbox-guest-additions-iso

.iso文件和guest虚拟机添加CD的OSE版本的映像将安装在主机目录/usr/share/virtualbox/VBoxGuestAdditions.iso中。在虚拟机的设置中将该.iso文件挂载为CD。在客人中,您将可以使用安装程序访问CD-ROM。

从Virtual Box Manager安装Guest Additions

如果Guest Additions无法构建,我们可能需要另外安装Linux内核头文件(请参阅How do I install kernel header files?)或build-essential工具。也建议安装dkms(见下面 – 注4)。

virtualbox,guest-additions,ubuntu

virtualbox,guest-additions,ubuntu

选择设备 – >安装Guest Additions(或从Virtual Box Manager中按Host + D)Guest Additions CD .iso将被加载,但未安装在您的客户操作系统中。要安装,我们需要以root身份或从Autorun提示符(参见下文)运行安装程序脚本VBoxLinuxAdditions.run


GNOME经典

要安装Guest Additions,我们将在安装虚拟驱动器后在桌面上放置一个CD图标:

virtualbox,guest-additions,ubuntu

下一步是通过打开驱动器或通过从right-click上下文菜单中选择“使用自动运行提示打开”来在此已安装的CD上运行autorun.sh脚本(以root用户身份),如上所述。这将构建并安装所需的vbox内核模块。


Unity

客人添加的作品可以在启动器上显示为虚拟CD:

virtualbox,guest-additions,ubuntu

如果系统设置为自动运行CD,则应打开以下自动运行对话框(如果不选择CD符号,请选择打开,然后选择打开自动运行提示符)

virtualbox,guest-additions,ubuntu

在输入凭证以进行根访问之后,客户端添加的内容将从终端输出中看到:

virtualbox,guest-additions,ubuntu

Return关闭终端。


Note 1
Guest Additions need a reboot of your guest OS to take effect.

Note 2
In some systems the Virtual Box Guest Additions CD icon may not be shown on the desktop, but will be accessible from the Places menu. If the CD still was not there you may have to manually add the VBoxGuestAdditions.iso as a CD-ROM in the Virtual Box Manager Storage menu. In an Ubuntu host the disk image is in /usr/share/virtualbox/VBoxGuestAdditions.iso.

Note 3
In some systems (e.g. when running Xubuntu guests) we may not have an Autorun Prompt for the mounted CD. Then we can install the guest additions by opening a terminal on the mounted guest additions .iso to run sudo ./VBoxLinuxAdditions.run. In Lubuntu or Ubuntu Server guests we additionally need to install the GNU C compiler (gcc Install gcc) and the make Install make utility in the guest system to be able to compile the guest additions.

Note 4
Running DKMS in the guest OS will keep Guest Additions installed after a guest kernel update. It is not a prerequisite for Guest Additions but if used it should be installed before we install the Guest Additions.


从终端安装客户添加

如果Guest Additions安装不正确,我们可能无法启动到GUI。在这种情况下,我们需要引导持有Shift键来访问Grub菜单,在那里我们访问根shell,如以下问题所示(我们需要挂载文件系统读/写以继续):

Guest Additions .iso文件需要从Virtual Box Manager安装在/dev/cdrom上(参见上文)。然后,我们可以通过输入以下命令来安装Guest Additions:

mount /dev/cdrom /mnt              # or any other mountpoint
cd /mnt
./VBoxLinuxAdditions.run
reboot

删除客户添加

如果安装客户添加项时出现问题,或者客户操作系统在安装后无法启动,我们可能不得不删除添加项。这也可以通过运行位于客人/opt目录中的卸载脚本从我如何启动到root shell?完成。

cd /opt/<VirtualBoxAdditions-x.x.xx>/
sudo ./uninstall.sh

x.x.xx替换为当前版本的嘉宾添加项。

次佳解决方案

您也可以尝试以下操作(在Update Manager杀死它们之后必须重新安装客户机Addtition后,这对我有用)。在此找到解决方案

http://www.unixmen.com/install-guest-addition-in-ubuntu-1010-maverick-meerkat-fix/

综上所述:

sudo apt-get update
sudo apt-get install build-essential linux-headers-$(uname -r)
sudo apt-get install virtualbox-ose-guest-x11

这发现并更新了VirtualBox Guest Additions的正确版本,并且我的系统似乎再次正常工作,并且假设Guest Additions无法从菜单项安装,这也可以工作。

另一件值得注意的事情。我最初试图在鱼壳下运行 – 确保你使用bash(即在启动之前将”bash”键入终端)。


请注意更新的系统,该命令已更改为

sudo apt-get install virtualbox-guest-x11

第三种解决方案

在客户操作系统中,安装包virtualbox-guest-dkms。例如,使用终端应用程序,键入sudo apt-get install virtualbox-guest-dkms

第四种方案

Oracle提供的.iso上的标准”virtualbox-guest-additions”软件包具有针对不同客户操作系统的通用工具…

但是,Ubuntu有自己专用的Ubuntu-specific Guest Addon软件包…名为virtualbox-ose-guest-dkms and ..-x11 and ..-utils

这些’virtualbox-ose-guest-*’程序包可识别DKMS。"(DKMS is a framework designed to allow individual kernel modules to be upgraded without changing the whole kernel.)"

这里是我在5-6个月前就这个问题询问的一个问题的链接… How can I get Compiz to work in a VirtualBox VM

第五种方案

以下是我最终运行的步骤,但如上面所述,用户名为’pcworld’,但实际上可能只有最后一个命令是需要的。我永远不会知道,但我想分享以防止其他人有所帮助:

sudo apt-get install virtualbox-guest-additions-iso
sudo apt-get update 
sudo apt-get dist-upgrade
sudo apt-get install virtualbox-guest-x11

并且不要忘记将您的VirtualBox实例设置为在您的实例的”Display”设置部分下使用128MB视频RAM和启用3D加速,以获得良好的性能。

第六种方案

这适用于Ubuntu Server 14.04客户VM(无GUI):

编辑:也适用于Ubuntu Server 15.04和16.04

1)安装dkms。从客人来看:

sudo apt-get install dkms

2)从VirtualBox VM窗口菜单中选择:Devices – >插入Guest Additions CD映像…

3)使用blkid标识CD-ROM设备。从客人来看:

sudo blkid

输出中的其中一行应该如下所示:

/dev/sr0: LABEL="VBOXADDITIONS_4.3.16_95972" TYPE="iso9660"

第一部分(/dev/sr0)是CD-ROM器件的名称。

4)安装CD(用上面找到的设备名称替换/dev/sr0):

sudo mount /dev/sr0 /media/cdrom/

5)运行Guest Additions安装程序:

sudo /media/cdrom/VBoxLinuxAdditions.run

6)重新启动客人。

第七种方案

以下是在VM内部安装VirtualBox Guest Additions内核模块的手动步骤:

  1. 下载ISO文件,例如

    wget http://download.virtualbox.org/virtualbox/5.0.20/VBoxGuestAdditions_5.0.20.iso -P /tmp
    
  2. 安装ISO文件:

    sudo mount -o loop /tmp/VBoxGuestAdditions_5.0.20.iso /mnt
    
  3. 运行安装程序(在sh调试后添加-x):

    sudo sh /mnt/VBoxLinuxAdditions.run
    

要找到正确版本的ISO文件,请在:http://download.virtualbox.org/virtualbox/上查看


如果您使用的是Vagrant,则通过执行以下命令可以简化安装过程:

vagrant plugin install vagrant-vbguest
vagrant up
vagrant vbguest

第八种方案

这个过程很简单。

在Virtual Box菜单中选择Devices>插入Guest Additions CD Image ….

以下弹出窗口将出现在您的Ubuntu桌面上:

virtualbox,guest-additions,ubuntu

选择Run和Guest Additions将自动安装。

第九种方案

必须安装virtualbox-guest-additions软件包。此外,可能看起来什么都没有发生,但所有“安装客人增加”按钮做的是挂载光盘。您应打开文件管理器(Nautilus /Dolphin),选择”CD device”并运行安装程序。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/66.html,未经允许,请勿转载。