Here’s a step-to-step recipe for completely removing VirtualBox (and all of its bits) from Ubuntu 25.04. Feel free to skip steps that don’t apply (e.g. if you didn’t add Oracle’s repo).
1. Stop any running VMs & services
# (just in case) shut down all VMs
VBoxManage list runningvms | awk '{print $2}' | xargs -r basename | xargs -r -I{} VBoxManage controlvm {} poweroff
# unload kernel modules
sudo systemctl stop virtualbox
sudo rmmod vboxdrv vboxnetflt vboxnetadp vboxpci 2>/dev/null || true
2. Remove VirtualBox packages
First, see what’s installed:
dpkg -l | grep -i virtualbox
Then purge them all in one go:
sudo apt update
sudo apt remove --purge virtualbox*
sudo apt autoremove --purge
Note: the wildcard (virtualbox*) will match virtualbox, virtualbox-7.0, virtualbox-ext-pack, etc.
3. Clean up DKMS kernel modules
If you used DKMS to build the vboxdrv module, remove it:
dkms status | grep -i virtualbox
# for each version shown, run for example:
sudo dkms remove virtualbox/7.0.10 --all
4. Remove Oracle’s repository (if added)
Check and delete any VirtualBox source files:
ls /etc/apt/sources.list.d/ | grep -i virtualbox
sudo rm /etc/apt/sources.list.d/virtualbox*.list
sudo apt update
5. Delete user-level configs & VMs (optional)
Warning: this will wipe out all your VMs, snapshots & settings in your home folder!
rm -rf ~/.config/VirtualBox
rm -rf ~/VirtualBox\ VMs
# if you ever used the old (.VirtualBox) directory:
rm -rf ~/.VirtualBox
6. Final cleanup & verification
# make sure no vbox modules remain
lsmod | grep vbox
# one last autoremoval of orphaned packages
sudo apt autoremove
🎉 At this point VirtualBox binaries, kernel modules, configs and repos should be entirely gone from your system. If you spot anything leftover (which VirtualBox, dpkg -l | grep -i vbox), just drop back here and let me know!