A kernel upgrade with no matching initramfs is a boot that stalls before it starts, and update-initramfs is the fix. These examples match initramfs-tools version 0.142ubuntu25.8.
You will update the initramfs for the kernel you intend, verify the image exists, and see how the local configuration changes the scope of future updates. Allow about ten minutes plus the build time itself.
/boot, and sudo access for anything that writes.Start with a read-only inventory. uname reports the kernel currently running; the files in /boot show which initramfs images already exist:
$ uname -r
6.8.0-142-generic
$ ls -lh /boot/initrd.img-*
-rw-r--r-- 1 root root 73M ... /boot/initrd.img-6.8.0-139-generic
-rw-r--r-- 1 root root 73M ... /boot/initrd.img-6.8.0-142-generic
Your versions and sizes will differ. Record the exact kernel version you intend to affect: do not guess from a file's modification time, and do not assume the newest file is the running kernel.
Checkpoint: set a shell variable to the version you have checked. This does not change the system:
$ kernel_version=$(uname -r)
$ printf '%s\n' "$kernel_version"
6.8.0-142-generic
The blended configuration lives at /etc/initramfs-tools/update-initramfs.conf. Read it before changing anything:
$ sudo sed -n '1,120p' /etc/initramfs-tools/update-initramfs.conf
update_initramfs=yes
backup_initramfs=no
update_initramfs=yes is the normal default: it lets kernel packages trigger an update of the latest initramfs.update_initramfs=all broadens that to every known initramfs.update_initramfs=no disables the automatic action, useful on a remote machine where you want a more deliberate process.backup_initramfs=yes keeps a .bak copy of the previous image during an update. This installation leaves it disabled; a backup costs disk space but buys a convenient local rollback.Do not edit this file just to do a one-off update: the -k flag on the command itself is the cleaner tool for a single run, since a config change affects every later package action too.
Use -u for an image that already exists, and pass the version explicitly when accuracy matters:
$ sudo update-initramfs -u -k "$kernel_version"
update-initramfs: Generating /boot/initrd.img-6.8.0-142-generic
The exact hook messages vary with your installed packages. A successful run returns to the prompt with exit status zero. For more detail while investigating, add -v:
$ printf '%s\n' "$?"
0
$ sudo update-initramfs -u -k "$kernel_version" -v
Checkpoint: verify the target path after the update, a read-only check:
$ initrd_path="/boot/initrd.img-$kernel_version"
$ sudo stat -c '%n %s bytes %y' "$initrd_path"
/boot/initrd.img-6.8.0-142-generic 76273231 bytes ...
If the command says the image does not exist, stop and re-check the kernel version. -u updates an existing image; it does not create one that is missing.
-c creates a new initramfs. Use it with an exact, verified kernel version, and check first that nothing is there already:
$ test -e "/boot/initrd.img-$kernel_version" && echo 'already exists'
already exists
That check heads off an accidental duplicate attempt. If it confirms the file is genuinely absent and the kernel really is installed, create it:
$ sudo update-initramfs -c -k 'KERNEL_VERSION'
update-initramfs: Generating /boot/initrd.img-KERNEL_VERSION
Replace KERNEL_VERSION with the verified value, such as 6.8.0-142-generic; do not copy the placeholder literally. Creating an image for a kernel that is not actually installed will not make that kernel bootable.
The special version all changes the scope of the operation:
$ sudo update-initramfs -u -k all
With -u this means every installed kernel that already has an initramfs. With -c it means every installed kernel, full stop. That can take a while and write several large files, so reach for it when you have deliberately chosen that scope, not as a generic repair reflex.
Leaving out -k on -u selects the latest kernel by the command's own documented default. An explicit version is easier to audit, especially on a machine with several kernels or ahead of a remote reboot.
Warning: -d deletes an existing initramfs. Deleting the wrong image can remove a boot route, and the command will not put it back for you.
$ ls -l /boot/initrd.img-KERNEL_VERSION
$ sudo update-initramfs -d -k 'KERNEL_VERSION'
Only run this against a real version after confirming another suitable kernel and initramfs remain in /boot. To undo a mistaken deletion, recreate the image with -c -k, provided the matching kernel is still installed:
$ sudo update-initramfs -c -k 'KERNEL_VERSION'
Warning: never use -d -k all as a tidy-up shortcut. It removes every applicable initramfs at once and leaves your next recovery step entirely dependent on whatever kernels and packages are still present.
If an update fails, do not reboot to test it. Capture the error, check free space, and inspect the target image first:
$ df -h /boot /
$ ls -lh "/boot/initrd.img-$kernel_version" "/boot/initrd.img-$kernel_version.bak" 2>/dev/null
$ sudo update-initramfs -u -k "$kernel_version" -v
Low space, a failed hook or a missing module can leave an image unchanged or incomplete. The .bak file only appears when backups are enabled and an earlier image was preserved: do not delete it until the new image has passed your checks.
For a read-only view of an image's contents, use lsinitramfs if it is installed:
$ sudo lsinitramfs "/boot/initrd.img-$kernel_version" | head -n 20
An archive listing confirms the file can be read as an initramfs. It does not prove every storage driver or boot hook your machine needs is actually present, so chase down build errors rather than trusting a listing alone.
-u updated an existing image, or -c created a verified missing one.-k all was a deliberate choice, if used at all. Not a default reach./boot/initrd.img-VERSION is there and readable.