Ubuntu – dpkg cannot remove package > linux-restricted-modules

dpkgkernel

I'm having a couple of issues with my Ubuntu server currently. When using apt for anything it tells me:

The following packages will be REMOVED
    linux-restricted-modules-2.6.28-11-server 
    linux-restricted-modules-2.6.28-19-server

But the uninstall fails because the directories and images already do not exist.

dkpg --list | grep linux-restricted-modules

…returns this information:

rH  linux-restricted-modules-2.6.28-11-server 2.6.28-11.15   
rH  linux-restricted-modules-2.6.28-19-server 2.6.28-19.24       

So the r means I want it removed and I think the H means it only half exists on the system or something?

How to I remove whatever is left of this package so I can stop receiving these error messages?

Thanks.

EDIT:
Complete output of apt-get upgrade:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  linux-restricted-modules-2.6.28-11-server linux-restricted-modules-2.6.28-19-server
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 5,046kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 59849 files and directories currently installed.)
Removing linux-restricted-modules-2.6.28-11-server ...
rmdir: failed to remove `/lib/modules/2.6.28-11-server/volatile/': No such file or     directory
FATAL: Could not open '/boot/System.map-2.6.28-11-server': No such file or directory
update-initramfs: Generating /boot/initrd.img-2.6.28-11-server
Cannot find /lib/modules/2.6.28-11-server
update-initramfs: failed for /boot/initrd.img-2.6.28-11-server
dpkg: error processing linux-restricted-modules-2.6.28-11-server (--remove):
 subprocess installed post-removal script returned error exit status 1
Removing linux-restricted-modules-2.6.28-19-server ...
rmdir: failed to remove `/lib/modules/2.6.28-19-server/volatile/': No such file or     directory
FATAL: Could not open '/boot/System.map-2.6.28-19-server': No such file or directory
update-initramfs: Generating /boot/initrd.img-2.6.28-19-server
Cannot find /lib/modules/2.6.28-19-server
update-initramfs: failed for /boot/initrd.img-2.6.28-19-server
dpkg: error processing linux-restricted-modules-2.6.28-19-server (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-restricted-modules-2.6.28-11-server
 linux-restricted-modules-2.6.28-19-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Best Answer

Find the /var/lib/dpkg/info/linux-restricted-modules-2.6.28-11-server.postrm file and move it somewhere else, for example

sudo mv /var/lib/dpkg/info/linux-restricted-modules-2.6.28-11-server.postrm /var/tmp

Then run the apt-get upgrade again. If that works, do the same to the other package.

This is not the best way of doing this, but it should work. The postrm script is failing, because you no longer have the kernel 2.6.28-11-server installed.

Related Question