User Tools

Site Tools


js#vista.png msort nsort


Remove unremoveable package

I love Debian and it's packaging system. I have worked with just about every flavor of Linux and BSD there is over the years and Debian is, for me, the best when it comes to stable production servers. However, under certain circumstances, APT can leave you hanging. If this happens and you end up with a package that you just cannot get rid of here is the easy way to do it.

Recently while creating an OpenVZ OSSIM server template I ran into a small problem when doing a package mirroring install from the ISO install to the development OpenVZ container. basically I did the following.

On the ISO installed machine:

osn1:~# dpkg --get-selections |cut -f 1 >packages

in the OpenVZ container:

nochst:~# scp root@osn1:/root/packages .
nochst:~# apt-get install $(< packages)

APT threw errors for 5 packages at this point:


Obviously these errors are due to the fact that we are building an OpenVZ template in an OpenVZ container and have no actual Kernel, no access to kernel modules, and a limited /dev and /proc. The first 4 packages were simple to get rid of, but pfring just couldn't install and couldn't deinstall.

nochst:~# apt-get remove pfring
Running /usr/bin/apt-get remove pfring
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 987 kB disk space will be freed.
Do you want to continue [Y/n]? 
(Reading database ... 59406 files and directories currently installed.)
Removing pfring ...
WARNING: Couldn't open directory /lib/modules/2.6.32-19-pve: No such file or directory
FATAL: Could not open /lib/modules/2.6.32-19-pve/modules.dep.temp for writing: No such file or directory
dpkg: error processing pfring (--remove):
 subprocess installed post-removal script returned error exit status 1
configured to not write apport reports
                                      Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
nochst:~# aptitude remove pfring

What to do? Well, due to the fact that I have hit this small window of misfortune a few times in the past with APT, I decided to finally figure out how to fix this without completely losing my mind. Basically, it boils down to getting dpkg to remove the package without trying to delete the kernel module (which there is not even a directory for in the container).

First you have to get rid of all the package scripts.

nochst:~# rm /var/lib/dpkg/info/pfring.*

Next you tell dpkg to remove the package and force the removal of the package requiring installation.

nochst:~# dpkg --remove --force-remove-reinstreq pfring
(Reading database ... 
dpkg: warning: files list file for package `pfring' missing, assuming package has no files currently installed.
(Reading database ... 59397 files and directories currently installed.)
Removing pfring ...

Now, be advised; depending on how the package was built, you may still have orphaned files on the system from the package. However, in this case I can live with it as I still need everything from the package except the kernel module. ;)

debian/force-remove.txt · Last modified: 2020/02/24 11:16 (external edit)