Linux Wonโt Boot? Hereโs How to Fix Missing Kernel Files
๐ 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