Table of Contents#
- Prerequisites
- Step 1: Update Ubuntu Packages
- Step 2: Install Required Dependencies
- Step 3: Insert the Guest Additions CD Image
- Step 4: Mount the CD and Run the Installer
- Step 5: Reboot the VM
- Step 6: Verify the Installation
- Troubleshooting Common Issues
- Conclusion
- References
Prerequisites#
Before starting, ensure you have the following:
- A running Ubuntu 24.04 VM in VirtualBox (Desktop or Server edition).
- Admin privileges on the Ubuntu VM (you’ll need
sudoaccess). - An active internet connection (to download updates and dependencies).
- VirtualBox 7.0 or newer (older versions may lack Ubuntu 24.04 compatibility; download the latest VirtualBox here).
Step 1: Update Ubuntu Packages#
First, update your Ubuntu VM’s package index and upgrade existing packages to their latest versions. This ensures compatibility with new software (like Guest Additions) and reduces the risk of conflicts.
Open a terminal in Ubuntu (press Ctrl + Alt + T for Desktop) and run:
sudo apt update && sudo apt upgrade -ysudo apt update: Refreshes the list of available packages.sudo apt upgrade -y: Upgrades installed packages (the-yflag auto-confirms prompts).
Step 2: Install Required Dependencies#
Guest Additions require tools to compile kernel modules and match your system’s kernel version. Install these dependencies:
sudo apt install -y build-essential dkms linux-headers-$(uname -r)Let’s break down each package:
build-essential: Includes compilers (likegcc) and libraries needed to build software from source.dkms(Dynamic Kernel Module Support): Ensures Guest Additions modules are automatically rebuilt when your Ubuntu kernel updates (critical for long-term stability).linux-headers-$(uname -r): Installs kernel headers matching your running kernel (replace$(uname -r)with your kernel version, e.g.,6.8.0-31-generic).
Verify Kernel Headers Installation#
To confirm headers are installed, run:
dpkg -l linux-headers-$(uname -r)If you see ii in the output (e.g., ii linux-headers-6.8.0-31-generic), headers are installed. If not, re-run the dependency command or check for kernel updates with sudo apt upgrade linux-image-$(uname -r).
Step 3: Insert the Guest Additions CD Image#
VirtualBox includes an ISO image with Guest Additions. To mount it:
-
In the VirtualBox window, go to Devices > Insert Guest Additions CD Image (or press
Host + D, whereHostis usuallyRight Ctrlby default).- If the option is grayed out, VirtualBox may need to download the ISO first. Click Download when prompted (this takes ~50MB).
- If the ISO is already downloaded, navigate to Devices > Optical Drives > Choose a disk file and select
VBoxGuestAdditions.iso(usually stored inC:\Program Files\Oracle\VirtualBox\on Windows or/usr/share/virtualbox/on Linux hosts).
Step 4: Mount the CD and Run the Installer#
Ubuntu may auto-mount the Guest Additions CD, but if not, mount it manually:
Option 1: Auto-Mounted CD#
If a pop-up appears asking to “Run Software,” click Run (you may need to enter your sudo password).
Option 2: Manual Mount#
If auto-mount fails:
-
Create a mount point (if needed):
sudo mkdir -p /mnt/vboxadditions -
Mount the CD:
sudo mount /dev/cdrom /mnt/vboxadditions -
Navigate to the mounted directory and run the installer:
cd /mnt/vboxadditions sudo ./VBoxLinuxAdditions.run
What the Installer Does#
The VBoxLinuxAdditions.run script compiles and installs:
- Kernel modules (e.g.,
vboxguestfor core integration,vboxsffor shared folders). - Services for clipboard sharing and display resizing.
- Utilities like
VBoxControlfor VM management.
The installation takes 1–2 minutes. Look for ... Installation successful in the output to confirm success.
Step 5: Reboot the VM#
Guest Additions require a reboot to load kernel modules. Reboot your Ubuntu VM:
sudo rebootStep 6: Verify the Installation#
After rebooting, confirm Guest Additions are working with these checks:
1. Check Loaded Modules#
Run:
lsmod | grep vboxYou should see modules like vboxguest, vboxsf, and vboxvideo (e.g., vboxguest 401408 2 vboxsf).
2. Test Display Resizing#
Drag the VirtualBox window’s edge to resize it—the Ubuntu desktop should auto-adjust resolution.
3. Test Shared Clipboard#
- Copy text from your host OS (e.g., “Hello from host”).
- Paste it into an Ubuntu terminal or text editor (use
Ctrl + Shift + Vin the terminal). - Reverse the test (copy from Ubuntu, paste to host) to confirm bidirectional sharing.
4. Test Shared Folders (Optional)#
To set up a shared folder:
- In VirtualBox, go to Devices > Shared Folders > Shared Folders Settings.
- Click Add (
+), select a host folder (e.g.,C:\shared), check “Auto-mount,” and set a share name (e.g.,host_shared). - In Ubuntu, access the shared folder at
/media/sf_host_shared(you may need to add your user to thevboxsfgroup first:sudo usermod -aG vboxsf $USER, then reboot).
Troubleshooting Common Issues#
Issue 1: “Kernel Headers Not Found”#
Cause: Missing or mismatched kernel headers.
Fix: Reinstall headers with sudo apt install linux-headers-$(uname -r). If that fails, upgrade your kernel:
sudo apt upgrade linux-image-generic
sudo rebootIssue 2: “modprobe: FATAL: Module vboxguest not found”#
Cause: Installer failed to build modules (e.g., missing build-essential).
Fix: Reinstall dependencies and re-run the installer:
sudo apt install -y build-essential dkms
sudo /mnt/vboxadditions/VBoxLinuxAdditions.run # Re-run from the CD mount pointIssue 3: Secure Boot Blocks Modules#
Cause: Ubuntu’s Secure Boot prevents unsigned kernel modules.
Fix: Disable Secure Boot in your VM’s BIOS (press F12 during boot in VirtualBox) or sign the modules manually (advanced users only).
Issue 4: CD Image Not Detected#
Cause: ISO not mounted or corrupted.
Fix: Re-download the Guest Additions ISO via Devices > Insert Guest Additions CD Image or manually download it from VirtualBox’s website.
Conclusion#
Installing VirtualBox Guest Additions on Ubuntu 24.04 transforms your VM from a sluggish, limited environment into a seamless extension of your host OS. With improved performance, shared resources, and auto-resizing displays, you’ll work more efficiently whether you’re developing, testing, or learning.
Remember to update Guest Additions whenever you upgrade VirtualBox (repeat Steps 3–5 with the new ISO) to ensure compatibility with the latest kernel and features.