Sunsea's Blog

Debian安装VirtualBox增强功能

概述

在Windows下安装virtualbox,然后在虚拟机中安装各Linux发行版进行学习是一个很不错的方式。
但是虚拟机中安装完Linux各发行版后,显示窗口很小,不能全屏,不能鼠标无缝切换,不能跟Windows系统剪贴板互通,更不能更主机进行文件交换与共享,为了解决上述问题,需要在虚拟机中安装增强功能guest additions),如果虚拟机中安装的是Windows系统也是如此,Windows系统下比较简单,不赘述,这里以Debian 10为例,介绍一下安装过程。

安装依赖

在安装增强功能前,需要先安装kernel headers、DKMS框架和build-essential。
首先检查是否安装了上述文件。

dpkg -l | grep -E "dkms|linux-headers-$(uname -r)|build-essential"

如果显示结果类似下面

ii  build-essential                               12.6                         amd64        Informational list of build-essential packages
ii  dkms                                          2.6.1-4                      all          Dynamic Kernel Module Support Framework
ii  linux-headers-4.19.0-5-amd64                  4.19.37-5                    amd64        Header files for Linux 4.19.0-5-amd64

则表明都已安装完成,可以进行下一步,否则安装依赖

sudo apt update -y && apt upgrade
sudo apt install dkms linux-headers-$(uname -r) build-essential

安装增强功能

安装增强功能前首先需要挂载安装文件到系统,如下图所示

然后执行下面命令开始安装

sudo sh /media/cdrom0/VBoxLinuxAdditions.run

[scode type="yellow"]注意:挂载的安装文件在cdrom0中,否则自行更改文件路径。[/scode]
安装的过程会弹出新窗口,输出如下内容

Verifying archive integrity... All good.
Uncompressing VirtualBox 6.0.8 Guest Additions for Linux........
VirtualBox Guest Additions installer
Removing installed version 6.0.8 of VirtualBox Guest Additions...
update-initramfs: Generating /boot/initrd.img-4.19.0-5-amd64
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel 
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 4.19.0-5-amd64.
update-initramfs: Generating /boot/initrd.img-4.19.0-5-amd64
VirtualBox Guest Additions: Running kernel modules will not be replaced until 
the system is restarted

当出现VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted时,按任意键关闭窗口。
然后重启系统即可。

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »