When working with virtual machines, you’ll likely encounter the frustrating error message: “This system is currently not set up to build kernel modules” when attempting to install VirtualBox Guest Additions on Ubuntu 18.04.
This error creates a roadblock that prevents you from enjoying enhanced VM functionality like seamless mouse integration, shared folders, and proper screen resolution.
The complete error typically looks something like this:
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted
In this comprehensive guide, I’ll explain exactly why this error occurs and provide you with multiple proven solutions based on my experience working with virtualization technologies.
Read: How to add guest features to your Virtualbox on Ubuntu 18.04
At its core, this error appears because Ubuntu 18.04 doesn’t include the necessary development tools and kernel headers by default. These components are essential because VirtualBox Guest Additions needs to build kernel modules that integrate with your specific Linux kernel.
The missing components generally include:
Without these components, the kernel module building process will fail, preventing Guest Additions from installing correctly.
The most straightforward fix is to install the required development tools:
sudo apt-get update
sudo apt-get install build-essential gcc make perl dkms
This command installs:
build-essential
: A meta-package that includes compilation tools and librariesgcc
: The GNU C Compilermake
: The GNU build automation toolperl
: The Perl programming language interpreterdkms
: Dynamic Kernel Module Support for automatic rebuildingsudo reboot
Sometimes, the error persists because you need to specifically install kernel headers that match your running kernel version:
uname -r
sudo apt-get install linux-headers-$(uname -r)
The $(uname -r)
part automatically expands to your current kernel version (like 4.15.0-generic), ensuring you get the correct headers package.
sudo reboot
For persistent issues, a more thorough approach combines both previous solutions:
sudo apt-get update
sudo apt-get install build-essential gcc make perl dkms linux-headers-$(uname -r)
sudo reboot
After the reboot, insert the Guest Additions CD and run the installer:
sudo ./VBoxLinuxAdditions.run
If you’ve made multiple attempts to install Guest Additions, conflicting files might be causing issues. Here’s how to start fresh:
sudo apt-get purge virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
ls -al /lib/modules/$(uname -r)/updates/dkms
dpkg -l *virtualbox*
After applying these fixes, you can verify that your system is properly set up for building kernel modules:
ls -l /lib/modules/$(uname -r)/build
A successful setup will show a symbolic link pointing to your kernel headers directory, typically in /usr/src/linux-headers-[version]
.
gcc --version
make --version
If all these checks pass, your system should now be properly configured to build kernel modules.
Read: A Deep Dive into Linux Operating System Architecture: Components and Functions
Kernel headers are critical for building modules because they provide the necessary interface definitions that modules need to interact with the kernel. When you install kernel headers, you’re essentially giving your system the “blueprints” that define how to connect new code to the existing kernel.
For VirtualBox Guest Additions specifically, these headers enable the creation of custom drivers that integrate with your Ubuntu system. Without properly matching headers, the module building process cannot determine how to correctly interact with your kernel.
One common issue is when your kernel headers don’t match your running kernel version. Always verify the versions match:
uname -r # Shows running kernel version
apt list --installed | grep linux-headers # Shows installed header packages
The output from both commands should show matching version numbers.
If you’re using an older version of VirtualBox (like 5.2.12 mentioned in the error), consider updating to the latest version. Newer VirtualBox versions often include improved compatibility with current Ubuntu releases.
As one user reported, simply updating VirtualBox to version 5.2.22 resolved their installation issues completely.
If the Guest Additions CD doesn’t automatically launch the installer when inserted:
/media/yourusername/VBox_GAs_[version]
or on your desktop)sudo ./VBoxLinuxAdditions.run
cat /var/log/vboxadd-install.log
After successfully installing Guest Additions, verify that it’s working correctly:
lsmod | grep vbox
You should see several modules like vboxguest, vboxsf, and vboxvideo.
The DKMS package (which we installed earlier) helps maintain your Guest Additions across kernel updates by automatically rebuilding modules. However, after major Ubuntu updates, you might need to reinstall Guest Additions.
If you notice Guest Additions features stop working after a kernel update, simply repeat the installation process.
The “This system is currently not set up to build kernel modules” error in VirtualBox is almost always caused by missing development tools and kernel headers in Ubuntu 18.04. By installing the necessary packages—build-essential, gcc, make, perl, dkms, and matching kernel headers—you can resolve this issue and successfully install Guest Additions.
Remember that proper kernel module building capability is essential not just for VirtualBox Guest Additions but for any third-party drivers or kernel modules you might need to install in the future.
A: Ubuntu aims to provide a balance between functionality and system size. Development tools are excluded from the default installation to keep the system lightweight, as most regular users don’t need to compile software.
A: Possibly. Major Ubuntu version upgrades might require reinstalling Guest Additions, but the DKMS package helps maintain compatibility during minor kernel updates.
A: The same principles apply to newer Ubuntu versions, though package versions may differ. The commands sudo apt install build-essential dkms linux-headers-$(uname -r)
should work across most Ubuntu versions.
A: On your host system, open VirtualBox and click on “Help” → “About VirtualBox” to see the version number.
A: Yes, you can install them with sudo apt install virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
. However, these may not match your VirtualBox version exactly, so the CD method is usually preferred.
A: You can manually mount it with:
sudo mkdir -p /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom
sudo ./VBoxLinuxAdditions.run
A: You likely need to add your user to the vboxsf group:
sudo usermod -aG vboxsf $USER
Then log out and back in for the changes to take effect.
The post How to Fix System is Not Set Up to Build Kernel Modules Error in Ubuntu appeared first on net2.
If you’ve recently upgraded to Ubuntu 22.10 from version 22.04, you might have encountered an…
When developing software, particularly in languages like C and C++, crashes are inevitable. The dreaded…
Have you ever been working in your Ubuntu terminal when suddenly that jarring error sound…
If you’ve recently upgraded to Ubuntu 16.04 or newer with MySQL 5.7+, you might have…
Managing users and groups effectively is one of the most fundamental skills for any Linux…
Have you ever been in the middle of updating your Ubuntu container with a simple…