How to Install VirtualBox on Rocky Linux 8
If you’ve already wrestled with installing any VM tool on a RHEL‑derived distro and are ready for a smooth ride, this guide will walk you through getting Oracle’s VirtualBox up and running on Rocky Linux 8 without the usual “no matching packages” headaches.
Why you’ll want to do this
- You’re looking for an alternative to KVM that feels more like your old Windows VM manager.
- Your project needs a GUI‑based virtual machine to keep things simple.
- You’ve already set up other Linux distros and just need the same steps on Rocky.
Step 1: Get the Base System Ready
Rocky Linux 8 ships with a minimal kernel. Before VirtualBox can hook into it, you need to make sure the development tools are in place:
sudo dnf groupinstall "Development Tools" sudo dnf install -y kernel-devel-$(uname -r) dkms
VirtualBox’s kernel modules compile at install time. If your running kernel version (`uname -r`) doesn’t match the installed `kernel‑devel` package, you’ll see “module is not built for current kernel” errors. Installing both packages ensures the headers line up.
Real‑world note – I once hit a wall after an automatic kernel update on a server: the modules were still linked to the old kernel, and the VM launcher would just crash with a cryptic error about “module not found.” A quick reinstall of `kernel-devel` for the new kernel fixed it.
Step 2: Enable EPEL (Optional but handy)
VirtualBox’s RPMs are available from Oracle’s own repository, but many users prefer to pull the dependencies from EPEL first. If you don’t already have EPEL enabled:
sudo dnf install -y epel-release
After that run a quick update to make sure everything is up to date:
sudo dnf update -y
Step 3: Add Oracle’s VirtualBox Repository
Oracle hosts the official RPMs. Grab the repo file and key with these commands:
wget https://download.virtualbox.org/virtualbox/rpm/el/VirtualBox.repo sudo mv VirtualBox.repo /etc/yum.repos.d/
Now import the GPG key that signs the packages:
rpm --import https://www.virtualbox.org/download/oracle_vbox.asc
The repo tells DNF where to look for the correct version of VirtualBox that matches Rocky’s RHEL 8 compatibility layer. The key guarantees you’re installing genuine software, not some shady fork.
Step 4: Install VirtualBox
With everything set up, install the latest stable release:
sudo dnf install -y VirtualBox-7.0
If you’re stuck on a specific version, replace `VirtualBox-7.0` with the desired package name from Oracle’s site.
Heads‑up – I’ve seen users try to pull older 6.x packages onto Rocky 8 and end up with kernel module load failures. Stick with the latest 7.x unless you have a very good reason not to.
Step 5: Post‑Installation Tweaks
1. Enable virtualization in BIOS/UEFI
If you get “VT-x is disabled” or similar, reboot into your firmware settings and enable Intel VT‑x (or AMD SVM). Without that, VirtualBox won’t run any VMs.
2. Add your user to the `vboxusers` group
sudo usermod -aG vboxusers $(whoami)
Then log out and back in so the group change takes effect.
3. Load kernel modules manually if needed
sudo modprobe vboxdrv
If you get “module not found” again, double‑check that the `kernel-devel` matches your running kernel.
Step 6: Test It Out
Launch VirtualBox from the application menu or via:
VirtualBox
Create a tiny VM (say Ubuntu Server) just to confirm the interface pops up and the virtual disk mounts without issue. If you see “No guest additions installed” that's fine—it just means you haven't added them yet, but the core engine is functioning.
Common Pitfalls & Fixes
| Symptom | Likely Cause | Quick Fix |
|---|---|---|
| `ERROR: Could not load module vboxdrv` | Mismatched kernel headers or missing `kernel-devel` | Reinstall `kernel-devel-$(uname -r)` and run `sudo /sbin/rcvboxdrv setup` |
| VM won’t start, “VT-x is disabled” | BIOS setting off | Enable VT‑x in your firmware before booting Rocky again |
| Package not found | Repo file missing or misnamed | Verify `/etc/yum.repos.d/VirtualBox.repo` exists and points to the correct URL |
> I once had a friend who kept installing VirtualBox on a freshly cloned Rocky image, only to find the launcher hanging forever. Turns out the `epel-release` was pointing at an older RHEL 7 mirror, so the dependencies never resolved. Switching to the fresh EPEL 8 mirror fixed it in seconds.
Wrap‑up
That’s all there is to it: a few package installs, a quick group tweak, and you’re ready to spin up VMs on Rocky Linux 8 just like any other Linux distro. If you run into a hiccup, the logs under `/var/log/vbox*` usually give a decent clue, or drop a line in the forum.