DEV Community

Stack All Flow
Stack All Flow

Posted on • Originally published at stackallflow.com on

How to Restore a System After Accidentally Removing All Kernels in Ubuntu?

kernel

I was trying to delete old kernels, but I must have deleted all of the kernels on my Ubuntu 11.04 laptop. Is there any way to fix this via USB boot or mounting hard drive on another system?

Accepted Answer

Boot into a live CD (or live USB), mount some systems, chroot into it and install the kernel. After a successful installation of the kernel, unmount the filesystems.

  1. Open Terminal
  2. Mount the Ubuntu partition: sudo mount /dev/sdXY /mnt
  3. Mount some special partitions:
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

Enter fullscreen mode Exit fullscreen mode
  1. (optional) When you are connected to a network, use the DNS servers from your Live environment (otherwise host names can possibly not be resolved):
cp /etc/resolv.conf /mnt/etc/resolv.conf

Enter fullscreen mode Exit fullscreen mode
  1. Chroot into the /mnt: sudo chroot /mnt
  2. Install the Linux kernel: apt-get install linux-image-generic (no sudo required as you are root after a chroot)
  3. After a successful installation of the kernel, get out the chroot and unmount some filesystems:
exit
sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev
sudo umount /mnt

Enter fullscreen mode Exit fullscreen mode
  1. Reboot and remove CD or USB: sudo reboot

The post How to Restore a System After Accidentally Removing All Kernels in Ubuntu? appeared first on Stack All Flow.

Top comments (0)