[Solved] Cannot delete VBoxDrv.kext and other kexts after uninstallation

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
NoSpam
Posts: 3
Joined: 3. Dec 2019, 11:44

[Solved] Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by NoSpam »

I uninstalled Virtualbox using the uninstaller provided in the img file. It got rid of everything except 4 kexts in:
/Library/StagedExtensions/Library/Application Support/VirtualBox/VBoxDrv.kext
/Library/StagedExtensions/Library/Application Support/VirtualBox/VBoxNetAdp.kext
/Library/StagedExtensions/Library/Application Support/VirtualBox/VBoxNetFlt.kext
/Library/StagedExtensions/Library/Application Support/VirtualBox/VBoxUSB.kext
I cannot delete them and cannot unload them using Terminal. Message:
Kext org.virtualbox.kext.VBoxDrv not found for unload request.
Failed to unload org.virtualbox.kext.VBoxDrv - (libkern/kext) not found.
So, how can I delete these kext files?
Screenshot 2019-12-03 at 08.17.55.png
Screenshot 2019-12-03 at 08.17.55.png (67.93 KiB) Viewed 7378 times
Last edited by socratis on 4. Dec 2019, 04:55, edited 2 times in total.
Reason: Marked as [Solved].
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by socratis »

NoSpam wrote:So, how can I delete these kext files?
Simply reboot.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
NoSpam
Posts: 3
Joined: 3. Dec 2019, 11:44

Re: Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by NoSpam »

I did it, many times, but it does not work. Those kexts do not go away after reboot, and I cannot unload or delete them.

PS: I am on macOS 10.15.1.
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by fth0 »

TL;DR: Execute "sudo kextcache -prune-staging" in a terminal.

The command "sudo kextcache -prune-staging" will remove all kernel extensions from the kernel extension staging area that are no longer present in their original location. When new kernel extensions are installed, they are copied into the staging area until they are approved by the user/administrator. So if you install VirtualBox, never approve the kernel extensions, and uninstall VirtualBox again, you probably end up where you are now. ;)

EDIT: When new kernel extensions are installed (e.g. into /Library/Extensions), they are additionally copied into the staging area (e.g. into /Library/StagedExtensions/Library/Extensions), where they are protected by the System Integrity Protection (SIP), even from (un-)installers. The approvals are kept in a separate database (/private/var/db/SystemPolicyConfiguration/KextPolicy). The command "sudo kextcache -prune-staging" will remove all kernel extensions from the kernel extension staging area that are no longer present in their original location. Educated Guess: If you install VirtualBox, and uninstall it again, you probably end up where you are now. ;)
Last edited by fth0 on 5. Dec 2019, 23:22, edited 1 time in total.
NoSpam
Posts: 3
Joined: 3. Dec 2019, 11:44

Re: Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by NoSpam »

It worked. Thank you very much!
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by socratis »

fth0 wrote:The command "sudo kextcache -prune-staging" will remove all kernel extensions from the kernel extension staging area that are no longer present in their original location.
And that's exactly the reason that I was so Spartan in my reply and just told 'NoSpam' to simply "Reboot", because everything I read about the "Staging area" was pointing exactly to what you mentioned as well, maybe I completely misunderstood what I read... :?
"Never instruct others to do something, unless you've done it yourself." (Socratis)
Marking as [Solved]...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: [Solved] Cannot delete VBoxDrv.kext and other kexts after uninstallation

Post by fth0 »

Digging a little bit deeper, I'll have to rephrase some of my statements, but the part you quoted is (of course) correct, because it's from the kextcache man page. I'll update my previous post.
Post Reply