分类目录归档:Linux

VirtualBox虚拟机Debian系统不能调整分辨率的解决办法

作者:余俊峰 tobecontinued.cn

Linux虚拟机安装后默认分辨率最大只有1024*768,“视图-虚拟显示屏1”的分辨率选项不可用。虚拟机显卡驱动没有安装,需要“安装增强功能”后才能调整分辨率。

选择“设备-安装增强功能”,提示错误:

# sh VBoxLinuxAdditions.run
Verifying archive integrity… All good.
Uncompressing VirtualBox 5.1.14 Guest Additions for Linux………..
VirtualBox Guest Additions installer
Copying additional installer modules …
Installing additional modules …
vboxadd.sh: Building Guest Additions kernel modules.
Failed to set up service vboxadd, please check the log file
/var/log/VBoxGuestAdditions.log for details.

/var/log/VBoxGuestAdditions.log:

vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed..

/var/log/vboxadd-install.log:

/opt/VBoxGuestAdditions-5.1.14/src/vboxguest-5.1.14/build_in_tmp: 67: /opt/VBoxGuestAdditions-5.1.14/src/vboxguest-5.1.14/build_in_tmp: make: not found
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

当然,之前已经安装了gcc make等编译需要的包。这里发生错误的原因是Linux内核开发包没有正确安装,导致不能编译增强功能包源代码。

一、安装Linux安装内核开发包

查看已安装内核发行号

#uname -r
3.16.0-4-amd64

查看已安装内核开发包版本是否与内核发行版一致

#dpkg -l | grep linux-headers

如果版本不一致或没有安装内核开发包,现在安装

#apt-get install linux-headers-$(uname -r)

安装后:

#dpkg -l | grep linux-headers

linux-headers-3.16.0-4-amd64 3.16.39-1 amd64 Header files for Linux 3.16.0-4-amd64
linux-headers-3.16.0-4-common 3.16.39-1 amd64 Common header files for Linux 3.16.0-4

二、重新执行“安装增强功能”成功

sh VBoxLinuxAdditions.run
Verifying archive integrity… All good.
Uncompressing VirtualBox 5.1.14 Guest Additions for Linux………..
VirtualBox Guest Additions installer
Removing installed version 5.1.14 of VirtualBox Guest Additions…
Copying additional installer modules …
Installing additional modules …
vboxadd.sh: Building Guest Additions kernel modules.
vboxadd.sh: Starting the VirtualBox Guest Additions.

You may need to restart the Window System (or just restart the guest system)
to enable the Guest Additions.

重启虚拟机后就可以调整分辨率了。