Page 1 of 1

Kernel modules not removed after a "sudo apt purge"

Posted: 27. Aug 2018, 15:47
by socratis
This is about an issue that was discussed over at the IRC channel with user 'tomreyn'. Since their account hasn't transitioned yet to the OSSO, I'm posting this for them. Setup:
  • Ubuntu 16.04/18.04, potentially others. I recreated the scenario in a Ubuntu 16.04 VM (no, it's not about nested virtualization). I will describing my setup since it's reproducible at will.
  • Ubuntu is not up to date, kernel-wise. Mine is "frozen" (snapshot) with the following kernel, but any old installer will definitely not be up to date, and will require a kernel update:
    $ uname -a
    Linux VB-Ubuntu 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:54:58 UTC 2017 i686 i686 i686 GNU/Linux
  • Install VirtualBox. Any version should do, but let's go with the latest and greatest, 5.2.18. Install it with 'apt-get' following the instructions on the Debian-based distros in the Linux Downloads page.
  • After a successful installation, you should have the following in "/lib/modules/4.4.0-87-generic/misc". Note that there are additional .ko files, because I'm doing this inside a VM. I've "greyed" them out:
    $ ls -l /lib/modules/4.4.0-87-generic/misc
    total 940
    -rw-r--r-- 1 root root 440920 Aug 18 22:17 vboxdrv.ko
    -rw-r--r-- 1 root root 320844 Aug 18 21:36 vboxguest.ko
    -rw-r--r-- 1 root root  15068 Aug 18 22:17 vboxnetadp.ko
    -rw-r--r-- 1 root root  35512 Aug 18 22:17 vboxnetflt.ko
    -rw-r--r-- 1 root root  32704 Aug 18 22:17 vboxpci.ko
    -rw-r--r-- 1 root root  52400 Aug 18 21:36 vboxsf.ko
    -rw-r--r-- 1 root root  56772 Aug 18 21:36 vboxvideo.ko
  • Update the system with:
    sudo apt update && sudo apt full-upgrade
  • The new kernel is successfully installed and the VirtualBox modules as well:
    $ uname -a
    Linux VB-Ubuntu 4.4.0-133-generic #159-Ubuntu SMP Fri Aug 10 07:26:31 UTC 2018 i686 i686 i686 GNU/Linux
    
    $ ls -l /lib/modules/4.4.0-133-generic/misc/
    total 956
    -rw-r--r-- 1 root root 444352 Aug 18 22:54 vboxdrv.ko
    -rw-r--r-- 1 root root 324924 Aug 18 22:47 vboxguest.ko
    -rw-r--r-- 1 root root  15316 Aug 18 22:54 vboxnetadp.ko
    -rw-r--r-- 1 root root  36420 Aug 18 22:54 vboxnetflt.ko
    -rw-r--r-- 1 root root  33092 Aug 18 22:54 vboxpci.ko
    -rw-r--r-- 1 root root  53364 Aug 18 22:47 vboxsf.ko
    -rw-r--r-- 1 root root  57156 Aug 18 22:47 vboxvideo.ko
And this is where the problem comes. If you want to clear the installation with:
  • 
    sudo apt purge linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic
the older modules are supposed to be removed, but they're not. Note that the GAs modules *were* successfully removed:
$ sudo apt purge linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic

$ ls -l /lib/modules/4.4.0-87-generic/misc/
total 956
-rw-r--r-- 1 root root 440920 Aug 18 22:17 vboxdrv.ko
-rw-r--r-- 1 root root  15068 Aug 18 22:17 vboxnetadp.ko
-rw-r--r-- 1 root root  35512 Aug 18 22:17 vboxnetflt.ko
-rw-r--r-- 1 root root  32704 Aug 18 22:17 vboxpci.ko