Removed Kernel by mistake

I got problems with a linux machine with a very small /boot partition. It wouldn't install any updates anymore and would complain about boot partition being full.

I found out that many kernel versions were stored in this partition, and I did a bit of cleanup -- which turned out quite bad because I deleted the active kernel in the process. I got nice error messages such as:

Kernel panic - not syncing: VFS: 
unable to mount root fs on unknown block(0,0)
not tainted 3.5.0.-25-generic ubuntu
missing initrd.img-3.5.0-25-generic

To fix that, one has to boot a live CD and chroot onto the broken system:

1. Run the live CD and start a gnome-terminal (Alt + F2 → gnome-terminal).

2.Issue the following command to mount your system (change sda1 to whatever your system partition name is - the output of the command fdisk -l should give you an idea):

sudo mkdir /mnt/ubuntu
sudo mount /dev/sda1 /mnt/ubuntu

3. You need to bind a couple of local directories to the chroot environment:

for i in proc sys dev; do sudo mount --bind /$i /mnt/ubuntu/$i; done

4. Enable DNS resolving in the chroot environment (should give you internet access):

sudo cp /etc/resolv.conf /mnt/ubuntu/etc/resolv.conf

5. Now it's time to get into your broken system (note, that you will be the almighty root user in the system, so be careful what you do):

sudo chroot /mnt/ubuntu
apt-get install linux-generic linux-headers-generic

6. After you've tampered with the system, you type exit to leave your system and then do the above steps in reverse order:

sudo rm /mnt/ubuntu/etc/resolv.conf
sudo umount /mnt/ubuntu/dev
sudo umount /mnt/ubuntu/sys
sudo umount /mnt/ubuntu/proc
sudo umount /mnt/ubuntu

7. Reboot without the CD and hope for the best.

source source 2

Page top