How to Install VirtualBox on Fedora

VirtualBox lets you run multiple operating systems on a single machine without rebooting. As a result, you can test Linux distributions, run Windows applications, create isolated development environments, or set up network labs without dedicated hardware. This guide walks through installing VirtualBox on Fedora using the official Oracle repository, configuring the required kernel modules, and setting up the Extension Pack for USB device support and other enhanced features.

Choose Your VirtualBox Version

Oracle maintains two active VirtualBox release branches. Once installed, updates within your chosen branch arrive automatically through the repository when you run dnf upgrade. However, major version upgrades (such as 7.1 to 7.2) require manual package changes since each version is a separate package. The following table summarizes the available options:

VersionStatusBest ForChangelog
VirtualBox 7.2Latest stableMost users wanting current featuresView changes
VirtualBox 7.1Previous stableCompatibility with existing VMsView changes

For most users, VirtualBox 7.2 is recommended as it includes the latest performance improvements, guest OS support, and security fixes. This guide demonstrates installation with VirtualBox 7.2, but you can substitute VirtualBox-7.1 in the install command if you need the previous release for compatibility reasons.

Update Fedora Before Installation

Before installing VirtualBox, first ensure your system is current. This step provides the latest security patches and, more importantly, ensures package dependencies resolve correctly. Run the following command to refresh the package database and apply any pending updates:

sudo dnf upgrade --refresh

The --refresh flag forces DNF to fetch fresh metadata from all enabled repositories, even if the local cache hasn’t expired. If updates were applied, consider rebooting before continuing, especially if the kernel was updated.

Install Build Dependencies

VirtualBox compiles kernel modules during installation and after each kernel update. Because of this, these modules require development headers and build tools. First, install the C development environment:

sudo dnf install @c-development

This group provides gcc, make, automake, and other essential build tools. Next, install the kernel development packages along with additional libraries that VirtualBox requires:

sudo dnf install kernel-devel kernel-headers dkms qt5-qtx11extras elfutils-libelf-devel zlib-devel

Here’s what each package provides:

  • kernel-devel and kernel-headers provide headers and build infrastructure for compiling kernel modules
  • dkms provides Dynamic Kernel Module Support, which automatically rebuilds VirtualBox modules after kernel updates
  • qt5-qtx11extras is the X11 support library required by the VirtualBox GUI
  • elfutils-libelf-devel and zlib-devel are development libraries for building kernel modules

The kernel-devel package version should match your running kernel. If you recently updated the kernel and haven’t rebooted, the installed kernel-devel may target the new kernel rather than the currently running one. Reboot before continuing if you applied kernel updates in the previous step.

Add the VirtualBox Repository

Oracle provides an official repository for Fedora that contains the latest VirtualBox releases. First, download the repository configuration file:

sudo wget https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo -P /etc/yum.repos.d/

Before installing packages, you should import Oracle’s GPG signing key so that DNF can verify package authenticity:

sudo rpm --import https://www.virtualbox.org/download/oracle_vbox_2016.asc

Next, disable repository metadata signature verification. This step is necessary because metadata verification can cause errors with the Oracle repository on newer Fedora releases:

sudo dnf config-manager setopt virtualbox.repo_gpgcheck=0

Finally, verify the repository is enabled and accessible:

dnf repolist | grep virtualbox

Expected output (the version number matches your Fedora release):

virtualbox            Fedora XX - x86_64 - VirtualBox

Install VirtualBox

With the repository configured, you can now install VirtualBox. If needed, replace the version number with your preferred release:

sudo dnf install VirtualBox-7.2

During installation, DNF downloads the package and its dependencies. In addition, it runs the DKMS module builder to compile VirtualBox kernel modules for your running kernel. Consequently, this process takes a few moments to complete.

After the installation completes, verify that it succeeded by checking the installed version:

vboxmanage --version

Expected output (version number varies based on installed release):

7.x.xrNNNNNN

The version string shows the VirtualBox release followed by the build revision number.

Enable the VirtualBox Kernel Service

VirtualBox requires the vboxdrv kernel module to communicate with your processor’s virtualization extensions. Therefore, you need to enable and start the VirtualBox service:

sudo systemctl enable vboxdrv --now

The --now flag starts the service immediately in addition to enabling it for future boots. To confirm the service is running, check its status:

systemctl status vboxdrv

Expected output:

● vboxdrv.service - VirtualBox Linux kernel module
     Loaded: loaded (/usr/lib/modules-load.d/virtualbox.conf; enabled)
     Active: active (exited)
      Tasks: 0 (limit: 18851)
     Memory: 0B
        CPU: 0

The active (exited) status indicates the kernel modules loaded successfully. This is normal behavior for a module-loading service.

Add Your User to the vboxusers Group

VirtualBox requires users to be members of the vboxusers group to access USB devices and other hardware features from within virtual machines. To enable this access, add your user account to this group:

sudo usermod -aG vboxusers $USER

Group membership changes require you to log out and log back in, or reboot. After logging back in, verify your group membership:

groups $USER

Expected output showing vboxusers in the list:

username : username wheel vboxusers

Launch VirtualBox

You can now open VirtualBox from the terminal:

virtualbox

Alternatively, you can search for “VirtualBox” in Activities and launch the application from there. Once opened, the VirtualBox Manager window displays any existing virtual machines and provides options to create new ones.

Install the VirtualBox Extension Pack

The VirtualBox Extension Pack is an optional component that adds features not included in the base installation. Specifically, it provides:

  • USB 2.0 and USB 3.0 device support
  • VirtualBox Remote Desktop Protocol (VRDP)
  • Host webcam passthrough
  • Disk image encryption with AES
  • PXE boot for Intel network cards

The Extension Pack version must match your installed VirtualBox version exactly. To ensure compatibility, first retrieve your VirtualBox version:

VERSION=$(vboxmanage --version | cut -dr -f1)
echo $VERSION

Expected output (your version number will vary):

7.x.x

Next, download the matching Extension Pack:

wget "https://download.virtualbox.org/virtualbox/${VERSION}/Oracle_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack"

Then, install the Extension Pack using vboxmanage:

sudo vboxmanage extpack install Oracle_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack

When prompted, type y and press Enter to accept the Oracle license terms. Finally, verify the Extension Pack installed correctly:

vboxmanage list extpacks

Expected output:

Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      7.x.x
Revision:     NNNNNN
Edition:      
Description:  Oracle Cloud Infrastructure integration, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe, full VM encryption.
VRDE Module:  VBoxVRDP
Crypto Module: VBoxPuelCrypto
Usable:       true 
Why unusable: 

Once verified, clean up the downloaded file:

rm Oracle_VirtualBox_Extension_Pack-${VERSION}.vbox-extpack

Install Guest Additions in Virtual Machines

Guest Additions are drivers and utilities installed inside the virtual machine that significantly improve performance and usability. Without Guest Additions, your VMs will have limited display resolution, require manual mouse capture, and lack shared folder support.

Guest Additions Features

Installing Guest Additions provides several important capabilities:

  • Seamless mouse integration: Move the mouse freely between host and guest without pressing a release key
  • Dynamic display resizing: The guest screen automatically adjusts when you resize the VM window
  • Shared folders: Access host directories from within the guest operating system
  • Shared clipboard: Copy and paste text and files between host and guest
  • Time synchronization: Keep the guest clock accurate relative to the host

Install Guest Additions on Linux Guests

For Linux guests, you need to install build tools before mounting the Guest Additions ISO. First, start your virtual machine and open a terminal inside the guest. Then install the required packages:

For Fedora and RHEL-based guests:

sudo dnf install kernel-devel kernel-headers gcc make perl bzip2

For Ubuntu and Debian-based guests:

sudo apt install build-essential linux-headers-$(uname -r)

Next, insert the Guest Additions CD image by selecting Devices > Insert Guest Additions CD image from the VirtualBox menu. If the CD doesn’t auto-mount, mount it manually:

sudo mkdir -p /mnt/cdrom
sudo mount /dev/cdrom /mnt/cdrom

Then run the installer:

sudo /mnt/cdrom/VBoxLinuxAdditions.run

Finally, reboot the virtual machine to activate the new drivers:

sudo reboot

Install Guest Additions on Windows Guests

For Windows guests, the process is simpler since no build tools are required. With the Windows VM running, select Devices > Insert Guest Additions CD image from the VirtualBox menu. Windows should auto-detect the CD and prompt to run it. If not, open File Explorer and run VBoxWindowsAdditions.exe from the CD drive. Follow the installation wizard, accept the driver installation prompts, and reboot when finished.

Enable Shared Folders

After installing Guest Additions, you can configure shared folders to exchange files between host and guest. First, shut down the VM. In the VirtualBox Manager, select your VM and click Settings > Shared Folders. Click the folder icon with a plus sign to add a new share, then specify the host folder path and a share name.

For Linux guests, add your user to the vboxsf group so you can access the shared folder without root privileges:

sudo usermod -aG vboxsf $USER

Log out and back in for the group change to take effect. The shared folder appears in /media/sf_<sharename> on Linux guests.

Troubleshoot Common Issues

Kernel Module Fails to Load

If virtual machines fail to start with errors about missing kernel modules, the VirtualBox kernel modules may not have built correctly. To fix this, rebuild them manually:

sudo /usr/lib/virtualbox/vboxdrv.sh setup

If you see errors about missing kernel headers, install the matching kernel-devel package for your running kernel. For more details on kernel headers, see our guide on installing Linux kernel headers on Fedora:

sudo dnf install kernel-devel-$(uname -r)

After installing the headers, rebuild the modules again with the vboxdrv.sh setup command.

Secure Boot Blocks Kernel Modules

Systems with UEFI Secure Boot enabled may refuse to load unsigned kernel modules. You have two options:

  1. Disable Secure Boot. Access your UEFI/BIOS settings during boot and disable Secure Boot. This is the simplest solution but reduces system security.
  2. Sign the VirtualBox modules. Create a Machine Owner Key (MOK), sign the modules, and enroll the key with Secure Boot. This process is more complex but maintains Secure Boot protection.

Check if Secure Boot is enabled:

mokutil --sb-state

If the output shows “SecureBoot enabled” and VirtualBox modules fail to load, consider option 1 or research MOK signing for your specific use case.

Modules Break After Kernel Updates

DKMS should automatically rebuild VirtualBox modules when you install new kernels. However, if this doesn’t happen, you can manually trigger a rebuild:

sudo dkms autoinstall

Verify the modules are built for your current kernel:

dkms status

Expected output showing modules are installed for your kernel:

vboxhost/7.x.x, 6.x.x-xxx.fc4x.x86_64, x86_64: installed

The output lists VirtualBox modules with status installed for your running kernel version. If you see added instead of installed, the modules need to be built using sudo dkms autoinstall.

Update VirtualBox

VirtualBox updates arrive through the Oracle repository. Apply updates alongside your regular system maintenance:

sudo dnf upgrade --refresh

This command updates VirtualBox to the latest version within your installed branch (for example, 7.2.0 to 7.2.1). However, major version upgrades require manual intervention since VirtualBox-7.1 and VirtualBox-7.2 are separate packages. To upgrade from 7.1 to 7.2, install the new package:

sudo dnf install VirtualBox-7.2

DNF automatically removes the old version when installing the new one. After major VirtualBox upgrades, you must download a new Extension Pack version that matches the updated release. Follow the Extension Pack installation steps again to ensure version compatibility.

Remove VirtualBox

If you no longer need VirtualBox, you can remove it along with the Extension Pack and repository configuration.

First, remove the Extension Pack if installed:

sudo vboxmanage extpack uninstall "Oracle VM VirtualBox Extension Pack"

Next, remove the VirtualBox package (adjust the version number to match what you installed):

sudo dnf remove VirtualBox-7.2

DNF may prompt to remove orphaned dependencies that were installed alongside VirtualBox. Review the list and confirm to clean up your system.

Finally, remove the Oracle repository file:

sudo rm /etc/yum.repos.d/virtualbox.repo

Warning: Virtual machine files and configuration are stored in ~/VirtualBox VMs by default and are not removed automatically. Delete this directory manually if you want to remove all VirtualBox data permanently.

Conclusion

You now have VirtualBox installed on Fedora with kernel modules configured for virtualization and the Extension Pack enabling USB and remote desktop features. Additionally, with Guest Additions installed in your VMs, you benefit from seamless mouse integration, dynamic display resizing, and shared folders. As a result, virtual machines you create can run Windows, other Linux distributions, or specialized operating systems for testing and development. For production setups, consider configuring network bridging and regular VM snapshots to protect your work. If your use case involves running Linux containers rather than full operating systems, Docker on Fedora may be a lighter-weight alternative.

Leave a Comment