How to Fix Broken /vmlinuz and /initrd.img Symlinks After Kernel Uninstall on Ubuntu 8.04 LTS Server


2 views

When running sudo apt-get remove linux-image-2.6.24-24-server on Ubuntu 8.04 LTS Server, you'll encounter these warning messages:

The link /vmlinuz is a damaged link
Removing symbolic link vmlinuz
 you may need to re-run your boot loader[grub]
The link /initrd.img is a damaged link
Removing symbolic link initrd.img
 you may need to re-run your boot loader[grub]

The symlinks /vmlinuz and /initrd.img in the root directory typically point to the current kernel image and initramfs. During kernel removal, if these symlinks aren't properly updated to point to the new kernel (or if there's no fallback kernel), they become broken.

Your system will still boot using the previous kernel (if available) through GRUB's configuration. The broken symlinks primarily affect:

  • Manual kernel booting operations
  • Scripts that reference these paths
  • System maintenance utilities

First, verify your current kernel version:

uname -r

Then recreate the symlinks (replace X.X.XX-XX with your actual kernel version):

sudo ln -sf /boot/vmlinuz-X.X.XX-XX-server /vmlinuz
sudo ln -sf /boot/initrd.img-X.X.XX-XX-server /initrd.img

While not always necessary, it's good practice to update GRUB:

sudo update-grub

For older Ubuntu versions (like 8.04), you might need:

sudo grub-install /dev/sda
sudo update-grub

Check the symlinks:

ls -l /vmlinuz /initrd.img

Expected output should show valid symlinks pointing to existing kernel files in /boot.

For future kernel operations, consider:

  1. Always keep at least one fallback kernel
  2. Verify symlinks after kernel changes:
for f in /vmlinuz /initrd.img; do
    [ -L "$f" ] || echo "Missing symlink: $f";
    [ -e "$f" ] || echo "Broken symlink: $f";
done

When uninstalling a kernel package in Ubuntu (specifically 8.04 LTS Server Edition in this case), you might encounter these warning messages:

The link /vmlinuz is a damaged link
Removing symbolic link vmlinuz
 you may need to re-run your boot loader[grub]
The link /initrd.img is a damaged link
Removing symbolic link initrd.img
 you may need to re-run your boot loader[grub]

This occurs when the symbolic links pointing to your kernel and initial RAM disk become broken after kernel removal. While the system may still boot (if you have other kernels installed), it's best to fix these symlinks properly.

First, check your existing symlinks:

ls -l /vmlinuz /initrd.img

If they're broken, you'll see output like:

lrwxrwxrwx 1 root root 28 2010-01-01 00:00 /initrd.img -> boot/initrd.img-2.6.24-24-server
lrwxrwxrwx 1 root root 25 2010-01-01 00:00 /vmlinuz -> boot/vmlinuz-2.6.24-24-server

Now verify what kernel versions you actually have installed:

ls /boot/vmlinuz-*
dpkg -l | grep linux-image

Assuming you have another kernel installed (let's say 2.6.24-23-server), recreate the symlinks:

sudo ln -sf /boot/vmlinuz-2.6.24-23-server /vmlinuz
sudo ln -sf /boot/initrd.img-2.6.24-23-server /initrd.img

For good measure, update your GRUB configuration. In Ubuntu 8.04, use:

sudo update-grub

This will regenerate your /boot/grub/menu.lst file with the current kernel configuration.

If you're dealing with this issue programmatically (like in a script), here's how to handle it:

#!/bin/bash
# Find the newest installed kernel
NEWEST_KERNEL=$(ls -1 /boot/vmlinuz-* | sort -V | tail -n1)
NEWEST_INITRD=$(ls -1 /boot/initrd.img-* | sort -V | tail -n1)

# Recreate symlinks
ln -sf $NEWEST_KERNEL /vmlinuz
ln -sf $NEWEST_INITRD /initrd.img

# Update GRUB
update-grub

To avoid this issue in the future when removing kernels:

sudo apt-get remove --purge linux-image-2.6.24-24-server linux-headers-2.6.24-24-server

The --purge option helps clean up configuration files more thoroughly. Always verify your symlinks after kernel operations:

ls -l /vmlinuz /initrd.img