How to Install VirtualBox Guest Additions in Debian

Quick Insight

You can fix a slow Debian VM and a tiny screen by adding Guest Additions. First, mount the CD image from the Devices menu of the guest window. If it fails to auto-run, open the media as Root and launch the shell script by hand. But before that, you must install the kernel headers with build-essential, module-assistant, and dkms from the Debian ISO or online repos. After a quick reboot, the desktop fills your whole display and shares files with the host in one smooth move.

In this guide, we will optimize the performance of Debian 9, 10, 11 & 12 virtual machines running on Oracle VM VirtualBox software. When we talk about performance, we will actually install Guest Additions, which are a basic need.

In fact, by installing drivers for the VM, we exploit the full potential of the host hardware in the virtual environment. In particular, you can maximize the capabilities of your Debian virtual machine. So, let’s examine how to install additional packages on a Debian guest machine!

Installing VirtualBox Guest Additions in Debian

Why Should I Install Guest Additions on Debian?

Finishing the first steps for setting up Debian on a virtual machine correctly is basic to this phase. When installing the operating system, you must pick the correct disk size and RAM amount. We have a full guide on this topic. If you have followed the settings in that guide fully, your job will now be much simpler.

In Oracle VM VirtualBox, you should add Guest Additions to your Debian virtual machine. This lets you use your host computer’s hardware.

For example, you can use your USB devices or webcam. This setup makes your virtual machine work much better. You can also use the whole screen with the right screen size.

First, you need to install the Guest Additions in your VirtualBox machine. Then, you can share files between your real computer and your virtual machine.

If you use an old version of Debian, you might have problems here. But if you have a new version like Debian 11, the driver is usually already there. So, I always say to use the latest version.

The base of these features lies in grasping the general logic of Guest Additions. In simple terms, all these add-ons make a bridge between the virtual machine and the real hardware. In fact, file sharing and USB support are all part of this link. This is a structure that works not only for Debian but for all systems.

How to Install Guest Additions on Debian 9, 10, 11 & 12

The installation process for the guest package remains consistent, regardless of your version of Debian. Essential for Linux distributions, the main benefits of this software are:

  • Enhanced graphics experience.
  • File sharing between the host and the VM.
  • Advanced mouse cursor integration.
  • Better compatibility with host computer hardware.
  • Ability to use various devices, such as audio support.

1. Add Guest Additions CD Image

Step 1

If you make your Debian virtual machine full screen, you will see a problem. The picture will not fit your screen correctly. This happens mainly because the Guest Additions are not installed. You need these add-ons for the screen to work right.

Low Screen Resolution of Virtual Machine

Step 2

Now, let’s install the software to make your Linux virtual machine better. First, click on ‘Devices’ in the VirtualBox menu.

Then click on the Insert Guest Additions CD image option from the options that open.

VirtualBox / Devices / Insert Guest Additions CD image

Step 3

Carefully read the warning in the “VBox_GAs” window. Then, if you trust the software, click the Run button.

Starting the Guest Additions Installation

Step 4

As in the image below, you may get the error that the CD image of the guest package could not be started automatically after mounting it to the system.

This error is due to not finding the required autorun program on your system. Click the OK button of the “Error autorunning software” error window.

Error Autorunning software

Step 5

To view the contents of the CD image, open File Manager, click VBox_GAs, and then Right-Click / Open as Root in the directory.

Run as Root

Step 6

Type your Root password and click Authenticate to confirm that the directory is opened with administrator rights.

Authenticating Your Account

Step 7

When you view the CD-ROM as Root, click the correct button again and select Open in Terminal.

Right-Click / Open in Terminal

Step 8

After opening the terminal, you can confidently use the “ls” command to check all the files currently stored in the media easily and quickly. In /media/cdrom0#, type “sh VBoxLinuxAdditions.run,” and press Enter.

ls
sh VBoxLinuxAdditions.run

sh VBoxLinuxAdditions.run

2. Install Kernel Packages for Debian

Step 1

Based on the image below, some packages are missing from your virtual system, preventing the successful installation of Guest Additions. To proceed with the installation, kindly ensure all necessary packages are installed.

Installing Additional Packages

Step 2

Now, on your guest machine, open the terminal in the desktop location.

Open in Terminal

Step 3

Add the image file to the virtual drive to find and install the necessary packages from the Debian ISO file without an Internet connection.

Adding the Debian ISO File

Step 4

Execute the “su -” command on the terminal, type your Root password, and press Enter. Next, execute the “sudo apt update” command.

su -
sudo apt update

In the image below, you need to attach the ISO image!

sudo apt update

Step 5

After executing the “sudo apt upgrade” command, press the Yes (Y) key on the line explaining that additional space is needed for the installation, then press Enter.

sudo apt upgrade

sudo apt upgrade

Step 6

Wait while new versions of existing packages are installed from the ISO file.

Installing Guest Additions

Step 7

After preparing your system, type the “sudo apt install build-essential module-assistant dkms” command and press Enter.

sudo apt install build-essential module-assistant dkms

sudo apt install build-essential module-assistant dkms

Step 8

To continue installing the Linux kernel packages, type Y and press Enter.

Confirming Disk Space Usage

Step 9

Be patient and wait while the kernel packages are being installed.

Setting up gcc

Step 10

And finally, execute the “m-a prepare” command to compile and install the Linux kernel modules.

m-a prepare

m-a prepare

Step 11

You can install virtual machine drivers after installing the necessary packages for your virtual system.

Guest Additions Installed

3. Try Reinstalling Guest Additions

Step 1

Display cdrom0 as Root and open the terminal again.

Rerunning Terminal in Directory

Step 2

Run the “sudo sh VBoxLinuxAdditions.run” command in the terminal to install Debian guest machine drivers.

sudo sh VBoxLinuxAdditions.run

sh VBoxLinuxAdditions.run

Step 3

After installing and preparing the necessary packages from the CD image, you will see that the Guest Additions have been successfully installed.

VirtualBox Guest Additions: Starting

4. Test Virtual Hardware

Step 1

To ensure that the settings you have made are adequate, execute the “shutdown -r now” command in the terminal to restart your Debian virtual computer.

shutdown -r now

shutdown -r now

Step 2

After the reboot, you can now change or resize the screen resolution of your Linux virtual operating system as you wish.

Ability to Adjust Virtual Machine Size

Step 3

You can also operate your system in Full mode using the View tab from the VirtualBox tool menu.

Now that you have finished the install with success, you might be curious about the results on a different system. The experience with similar additions in Linux Mint is nearly the same. If you check the steps there too, you will fully understand the logic of VirtualBox. This way, you will have no trouble even if you move to different distributions later.

Virtual PC Full Screen

Video

Video Thumbnail
Watch on YouTube

FAQ About Guest Additions on Debian

What troubles will I face in daily use if I do not have Guest Additions on my Debian virtual machine?

Honestly, your mouse cursor gets trapped inside the window. You have to press the right Ctrl key every time to free it. The screen resolution also stays stuck at a poor fixed value.
When you try to go full screen, you face big black borders. You cannot drag and drop files with the host. In addition, shared folders do not work.
What is more, when you plug in a USB stick, the virtual system ignores it. Delays or dropouts with the sound card are extra. In short, half the system works, the other half sulks.

I get an ‘Error autorunning software’ warning when I insert the installation CD. Should I panic?

No, this is a completely harmless situation. Your Debian desktop shows such a message because it cannot find the program to run the auto-start script. Just click OK and move on.
Open the file manager and go inside the CD drive. You will start the setup manually by right-clicking there and using ‘Open as Root’ or ‘Open in Terminal’. Many of my clients saw this error and abandoned the setup halfway.
Yet all you need to do is open a terminal inside a folder and type the ‘sh VBoxLinuxAdditions.run’ command. Enter your system password when asked and the job is done.

I type ‘sh VBoxLinuxAdditions.run’ in the terminal but it says kernel header files are missing. What does this mean and how do I get past it?

This error says that the build tools matching the virtual machine’s current kernel are not found. Do not worry, we will get past this wall with a few commands. First, update your system: ‘sudo apt update’ and then ‘sudo apt upgrade’.
Then install the needed compiler and module assistant. The command is: ‘sudo apt install build-essential module-assistant dkms’. When it asks for setup confirmation, press ‘Y’ and Enter. Wait a bit because a series of packages will download.
In the end, prepare the kernel module environment by running the ‘m-a prepare’ command. Now when you run the setup script inside the CD again, it will complete successfully in seconds.

The installation looks successful but I restarted the virtual machine and it still does not go full screen?

The first possibility is that the system was not really restarted. Logging out and logging back in is not enough. You must do a full reset with ‘shutdown -r now’. The second possibility is that the ‘Auto-resize Guest Display’ option is not checked in the View tab of the VirtualBox menu.
Check this setting and grab the window by the corner and resize it a little. The screen will start adapting to the size right away. On the other hand, if you are using an old Debian version, the graphics driver may not be fully compatible.
In such a case, picking a different resolution from the display settings and then switching back to the old one sometimes makes a magic touch.

After installing these additions, what practical differences will I feel right away in my daily workflow?

First of all, your mouse cursor flows like water between the host and the guest. No more lag. The file sharing part is the biggest comfort boost. You can take your documents from the host and drop them directly on the Debian desktop.
Copy-paste jobs also start working in both directions, both for text and files. You also do not struggle with network settings to use shared folders. Graphics performance gets visibly better.
Because the tearing and stuttering that happen when watching videos or browsing the interface are largely gone. Access to your webcam or USB stick is now just one click away.

Do the Guest Additions setup steps differ between Debian 12 Bookworm and older versions?

At its core, the process is completely the same. From Debian 9 to 12, the terminal commands do not change. On current versions like Debian 11 and 12, your advantage is that the dependency packages are fresher and problem-free. On older versions, the ‘build-essential’ package may sometimes not be found on the CD.
At such moments, you must connect to the internet and update the repos. If your system is very new, the guest additions setup script will not greet you with a message like ‘This distribution is not supported’.
In the end, VirtualBox developers adapt quickly to new Linux kernels. So whether you use Wheezy or Bookworm, if you follow the path I described, you will complete it without problems.

Conclusion

As a result, you should increase the functionality of your Debian virtual machine running on Oracle VM. To do this, you must install Guest Additions on your Debian PC. So you can start using your host PC’s hardware effectively.

Thanks to all the methods I discussed in our article, you can improve the graphics experience of your Debian VM. As a result, you can enable file sharing between the host and VM. Plus, of course, you get more advanced mouse cursor integration.

They'll Thank You for Discovering This Guide!

Ready to do your loved ones a huge favor with just one click? Knowledge grows as it is shared.

2 People Shared Their Experience

  1. Thanks this really helped me to install the guest additions, earlier this procedure used to simpler

    1. I’m glad you fixed your problem.

Share Your Opinion