21

I needed to regenerate initrd. Doing this:

update-initramfs -u -k all

threw up errors for a kernel I compiled and then deleted some time ago (because update-initramfs could not find the /lib/modules directory I had deleted of course).

I thought I had completely removed the kernel by deleting all its entries in /boot and directory in /lib/modules & running sudo update-grub (as in this answer), but apparently there are traces of it somewhere that I should probably clean up.

I read this and dug around in /usr/share/initramfs-tools but I couldn't figure it out.

In man update-initramfs I see that:

The use of "all" for the version string specifies update-initramfs to execute the chosen action for all kernel versions, that are already known to update-initramfs.

But how does it know them? Where does update-initramfs look for kernel versions?

Note: many months later... I added the answer to this question to the tag wiki for

Zanna
  • 72,312

2 Answers2

22

I had the same problem as you, I also thought I had completely removed the kernel by deleting all its entries in /boot and directory in /lib/modules & updating GRUB, but I found the one directory that is used by update-initramfs to keep track of the kernels:

/var/lib/initramfs-tools
Zanna
  • 72,312
thom
  • 7,742
1

Accepted answer was true until some years ago. Today, there is no more /var/lib/initramfs-tools file.

Instead, update-initramfs calls the command linux-version, which is part of the package linux-base. A linux-version list lists the currently installed kernels on that Linux system.

linux-version is a perl script. As I can see, it simply gets the list of the installed kernels by listing by doing a /boot/vmlinu[xz]-* pattern match (in the perl source file /usr/share/perl5/DebianLinux.pm).

peterh
  • 293
  • 5
  • 17