paul's picture

Today, we needed to clear out some old kernel from one of the servers we managed to free space in the boot partition of this server. Unfortunately, we got an error removing linux-ubuntu-modules-2.6.24-28-server package. We had the following errors:

Removing linux-ubuntu-modules-2.6.24-28-server ...
FATAL: Could not open '/boot/System.map-2.6.24-28-server': No such file or directory
update-initramfs: Generating /boot/initrd.img-2.6.24-28-server
Cannot find /lib/modules/2.6.24-28-server update-initramfs: failed for /boot/initrd.img-2.6.24-28-server
dpkg: error processing linux-ubuntu-modules-2.6.24-28-server (--remove):
subprocess post-removal script returned error exit status 1
Errors were encountered while processing: linux-ubuntu-modules-2.6.24-28-server

The problem was that the remove script required that the file /boot/System.map-2.6.24-28-server exist and that the directory /lib/modules/2.6.23-28-server exist. They were missing and the package could not be removed as a result. Worse still apt was now in a limbo state - no further update/changes could be run until this was fixed.

apt-get -f install did not work.

The solution involve restored the required missing files. So as root

touch /boot/System.map-2.6.24-28-server
mkdir /lib/modules/2.6.24-28-server

By doing this, apt-get -f install now works and the package is removed.