To make a long story short, I am stuck with a handful of unwanted, half-configured image packages that I am trying to get rid of:
$ dpkg -l |grep linux-im
iF linux-image-3.13.0-100-generic 3.13.0-100.147 i386 Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF linux-image-3.13.0-101-generic 3.13.0-101.148 i386 Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF linux-image-3.13.0-92-generic 3.13.0-92.139 i386 Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF linux-image-3.13.0-93-generic 3.13.0-93.140 i386 Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iF linux-image-3.13.0-96-generic 3.13.0-96.143 i386 Linux kernel image for version 3.13.0 on 32 bit x86 SMP
iH linux-image-extra-3.13.0-100-generic 3.13.0-100.147 i386 Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iH linux-image-extra-3.13.0-101-generic 3.13.0-101.148 i386 Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iH linux-image-extra-3.13.0-92-generic 3.13.0-92.139 i386 Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iH linux-image-extra-3.13.0-93-generic 3.13.0-93.140 i386 Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
iH linux-image-extra-3.13.0-96-generic 3.13.0-96.143 i386 Linux kernel extra modules for version 3.13.0 on 32 bit x86 SMP
These images are in fact useless, because my 32-bit 14.04 system lives in an OpenVZ container, which is solely responsible for the kernel. As you can see, a much older one:
$ uname -r
2.6.32-042stab116.2
Thus, unlike most similar questions focusing on how to remove old kernel images after routine upgrades, what I am trying to do here is to COMPLETELY PURGE ALL THESE 3.13 PACKAGES, which should not be there in the first place.
Here's a summary of my attempts so far.
Trying to remove/purge the packages the usual ways (apt-get
, apt
, aptitude
, it doesn't matter) does not seem to work, due to an apparent vicious circle.
sudo apt-get purge linux-image-3.13.0-100-generic linux-image-3.13.0-101-generic linux-image-3.13.0-92-generic linux-image-3.13.0-93-generic linux-image-3.13.0-96-generic linux-image-extra-3.13.0-100-generic linux-image-extra-3.13.0-101-generic linux-image-extra-3.13.0-92-generic linux-image-extra-3.13.0-93-generic linux-image-extra-3.13.0-96-generic
As you can see from the output, nothing gets actually removed. On the other hand, aptitude
manages to get a little further:
sudo aptitude purge linux-image-3.13.0-100-generic linux-image-3.13.0-101-generic linux-image-3.13.0-92-generic linux-image-3.13.0-93-generic linux-image-3.13.0-96-generic linux-image-extra-3.13.0-100-generic linux-image-extra-3.13.0-101-generic linux-image-extra-3.13.0-92-generic linux-image-extra-3.13.0-93-generic linux-image-extra-3.13.0-96-generic
At the end of this process, the *image-3.13*
s are gone, together with matching files and folders normally found in /boot
and in /lib/modules
, but the image-extra
s are still reported as half-installed (even though they appear to contain no files, as verified by dpkg -L
...)
Furthermore, dependencies are now broken, as repeating the purge at this stage causes apt to complain about missing files/folders in /boot
and in /lib/modules
. I tried to place dummy files at the expected locations, as suggested here, but in the end I run into the original errors. The following, I believe, is the crucial excerpt:
[...]
Removing linux-image-extra-3.13.0-101-generic (3.13.0-101.148) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-101-generic /boot/vmlinuz-3.13.0-101-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-101-generic /boot/vmlinuz-3.13.0-101-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-101-generic
E: /usr/share/initramfs-tools/hooks/fixrtc failed with return 1.
update-initramfs: failed for /boot/initrd.img-3.13.0-101-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-3.13.0-101-generic (--purge):
subprocess installed post-removal script returned error exit status 1
[...]
After trying, unsuccessfully, a supposedly nuclear option:
sudo dpkg --remove --force-remove-reinstreq package_name
I ran out of ideas.
dpgk
running the scripts in/etc/kernel/postrm.d
.