Linux Wonโ€™t Boot? Hereโ€™s How to Fix Missing Kernel Files

Linux Wonโ€™t Boot? Hereโ€™s How to Fix Missing Kernel Files
Photo by Spenser Sembrat / Unsplash

๐Ÿš€ Linux Wonโ€™t Boot? Hereโ€™s How to Fix Missing Kernel Files (vmlinuz and initrd.img)

If your Linux system fails to boot and displays errors like:

error: file '/vmlinuz' not found
error: file '/initrd.img' not found

it means that your kernel (vmlinuz) or initial RAM disk (initrd.img) is missing or corrupted. These files are essential for booting Linux, and their absence will prevent your system from starting.

๐Ÿ“Œ In this guide, youโ€™ll learn:
โœ… Why these files go missing
โœ… How to check if they are actually deleted
โœ… Step-by-step recovery methods
โœ… Best practices to prevent kernel file loss


๐Ÿ“Œ 1. Why Does Linux Fail to Boot?

Linux may fail to boot due to missing or corrupted kernel files. This issue is often caused by:

๐Ÿ”น Kernel file deletion or corruption โ€“ Accidental deletion, disk errors, or failed updates
๐Ÿ”น Kernel upgrade failure โ€“ The system failed to retain older versions
๐Ÿ”น GRUB misconfiguration โ€“ Bootloader settings do not point to the correct kernel
๐Ÿ”น /boot partition is not mounted โ€“ If /boot is a separate partition but not loaded correctly

Before proceeding with recovery, let's check whether the files are really missing!


๐Ÿ” 2. How to Check If Kernel Files Are Missing?

Before attempting recovery, confirm that vmlinuz and initrd.img are actually missing.

๐Ÿ”น Step 1: Check the /boot Directory

Run:

ls -lh /boot/

๐Ÿ“Œ If the files exist โ†’ Your issue is likely a GRUB misconfiguration.
๐Ÿ“Œ If the files are missing โ†’ Proceed to the recovery steps below.

๐Ÿ”น Step 2: Check If /boot Is Properly Mounted

mount | grep "/boot"

If nothing is returned, /boot is not mounted. Manually mount it:

mount /dev/sdX1 /boot

๐Ÿ“Œ Replace sdX1 with your actual /boot partition.

If the files are missing, continue with the recovery process below.


๐Ÿ”ง 3. Recovering a Missing Kernel (vmlinuz)

If your kernel image (vmlinuz) is missing, follow these steps to restore it.

๐Ÿ”น Method 1: Restore vmlinuz from Installation Media

โœ… Step 1: Mount the /boot partition

mount /dev/sdX1 /mnt

โœ… Step 2: Copy vmlinuz from installation media

cp /mnt/boot/vmlinuz-$(uname -r) /boot/vmlinuz

โœ… Step 3: If the file is compressed (.gz), decompress it

gunzip /boot/vmlinuz-$(uname -r).gz

โœ… Step 4: Update GRUB and reboot

grub-mkconfig -o /boot/grub/grub.cfg
reboot

๐Ÿ”ง 4. Recovering a Missing initrd.img

If initrd.img is missing, you must regenerate it, rather than simply copying it.

๐Ÿ”น Rebuild initrd.img Based on Your Linux Distro

๐Ÿ“Œ Debian/Ubuntu

update-initramfs -c -k $(uname -r)

๐Ÿ“Œ CentOS/Fedora/RHEL

dracut --force /boot/initramfs-$(uname -r).img

๐Ÿ“Œ Arch Linux

mkinitcpio -p linux

โœ… Final Step: Update GRUB and reboot

grub-mkconfig -o /boot/grub/grub.cfg
reboot

๐Ÿ›ก๏ธ 5. How to Prevent Kernel File Loss?

To prevent similar issues in the future, follow these best practices:

โœ… Regularly Back Up /boot

tar -czf /backup/boot_backup.tar.gz /boot

โœ… Ensure Correct Kernel Upgrades

apt list --installed | grep linux-image  # Debian/Ubuntu
rpm -qa | grep kernel  # CentOS/Fedora

โœ… Check Available Space in /boot Before Upgrading

df -h /boot

โœ… Update GRUB to Ensure the Correct Kernel Is Loaded

grub-mkconfig -o /boot/grub/grub.cfg

๐Ÿ“Š 6. Summary

Issue Solution
vmlinuz is missing Mount /boot, restore vmlinuz, and update GRUB
initrd.img is missing Rebuild initrd.img using update-initramfs or dracut
/boot partition is not mounted Run mount /dev/sdX1 /boot manually
Kernel upgrade caused old kernel deletion Back up /boot before upgrading and check available space
Prevention Regular backups, proper kernel upgrades, updating GRUB

๐Ÿ’ฌ Join the Discussion!

Have you ever faced a Linux boot failure?
What steps did you take to fix it?

๐Ÿ’ฌ Share your experiences and solutions in the comments below! ๐Ÿš€

๐Ÿ‘‰ If you're troubleshooting Linux file system errors, check out: How to Recover Files from the Linux lost+found Directory


Read more