Occasionally I see some of our Ubuntu machines having /boot partition filled up by the initrd files generated from old kernels which no longer were no longer installed on the machines.
root@matht232:/boot# uname -a
Linux matht232 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
root@matht232:/boot# dpkg -l linux-image-\* | grep ^ii
ii linux-image-5.3.0-40-generic 5.3.0-40.32~18.04.1 amd64 Signed kernel image generic
ii linux-image-generic-hwe-18.04-edge 5.3.0.46.102 amd64 Generic Linux kernel image
root@matht232:/boot# ls -1 /boot
config-5.3.0-40-generic
config-5.3.0-46-generic
grub
initrd.img-3.13.0-46-generic
initrd.img-4.15.0-88-generic
initrd.img-4.4.0-101-generic
initrd.img-4.4.0-122-generic
initrd.img-4.4.0-87-generic
initrd.img-5.3.0-40-generic
lost+found
System.map-5.3.0-40-generic
System.map-5.3.0-46-generic
vmlinuz-5.3.0-40-generic
vmlinuz-5.3.0-46-generic
I tried to remove these initrd
files manually, and they were generated again when a new kernel is installed. I haven’t figured how did this happened, until today!
Thanks to this ask ubuntu question, there are some left over initramfs generation rules in /var/lib/initramfs-tools/
.
root@matht232:/boot# ls -1 /var/lib/initramfs-tools/
3.13.0-46-generic
4.15.0-88-generic
4.4.0-101-generic
4.4.0-122-generic
4.4.0-87-generic
5.3.0-40-generic
In my situation, (yours is definitely different), I need to remove the older files, leaving the 5.3.0-40-generic
untouched. Generate
root@matht232:/boot# update-initramfs -d -k 3.13.0-46-generic
update-initramfs: Deleting /boot/initrd.img-3.13.0-46-generic
root@matht232:/boot# update-initramfs -d -k 4.15.0-88-generic
update-initramfs: Deleting /boot/initrd.img-4.15.0-88-generic
root@matht232:/boot# update-initramfs -d -k 4.4.0-87-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-87-generic
...
root@matht232:/boot# update-initramfs -d -k 5.3.0-40-generic`
Suprisingly, there were still unwated initrd
.
root@matht232:~# ls -1 /boot
config-5.3.0-40-generic
config-5.3.0-46-generic
grub
initrd.img-4.4.0-101-generic
initrd.img-4.4.0-122-generic
initrd.img-5.3.0-40-generic
lost+found
System.map-5.3.0-40-generic
System.map-5.3.0-46-generic
vmlinuz-5.3.0-40-generic
vmlinuz-5.3.0-46-generic
Again, in my situtation (I hope you don’t just follow this guide blindly), all I need to do last was to manually remove those files.
References: