How can I repair a system with a deleted kernel?
An option is a manual recovery:
Files are the easiest part. You can do what Ramchandra suggested, but if you want to preserve your apps you should avoid reinstalling (as that would, as you've seen, remove the apps.) If you want to avoid uninstalling the boot with a missing kernel:
Boot to LiveCD.
Using nautilus, open up the broken partition.
Navigate to /home/myusernamehere. All your files will be there.
Some other files you might want to save:
- /etc/apt/sources.list, if you have any manual repos.
After you are done with this, stick it onto a flash drive or email it to yourself.
Apps is a trickier part. I have come up with a somewhat roundabout solution that will take some time (most of it without you actively participating), but this should recover your apps (without settings/configurations)
Stick around LiveCD.
Navigate to /usr/lib. (It may take a while to load.)
Woah! Huge amount of folders. Open up gedit in liveCD.
Type this in gedit:
sudo apt-get install folder1 folder2 folder3
...Where folder1 folder2 folder3 are the names of the folders.
These are all the programs you have installed on ubuntu (I think). Some of these (about 50%, maybe more) come with the system, so the arent necessary, but a safe bet is just put everything.
Another place to look for apps is /etc and /etc/alternatives. (Update me if I am missing any spots, internet!)
Save the file as .sh and email or flash drive it.
Now, when you first start up your computer (after total reinstall) you can run this script to sudo apt-get all your programs that you previously had. They'll be good as new!
Boot from the livecd, mount the hard disk, and reinstall the kernel. For example:
sudo -s mount /dev/sda1 /mnt mount --bind /sys /mnt/sys mount --bind /proc /mnt/proc mount --bind /dev /mnt/dev chroot /mnt apt-get install linux-image-3.2.0-27-generic-pae
Did you try the recovery option? You can install Ubuntu over an exisiting Ubuntu installation - all your files will remain. Though if you modify system files, those changes will be wiped out.
To do so, at the installer select advanced partition and use your ubuntu installed partition as / .
I have not tested it though.
Related videos on Youtube
slashcrack 3 months
Because I wanted to get more free space on my HDD, I deleted old kernels (dont ask me why I was so mad.). I accidentally deleted the active kernel too (3.2.0-27 on Ubuntu 12.04).
First I couldn't boot. I installed the kernels 3.2.0-23 and 3.2.0-27 via a live system (see here).
Now, when I start my system now, I only get these lines:
mountall: Event failed fsck from util-linux 2.20.1 /dev/sda1: clean, 832254/40099840 files, 21092083/160394239 blocks * Stopping Flush boot log to disk * Stopping Enabling additional executable binary formats * Starting bluetooth daemon
Other PC specs:
- Intel i5 2500K 4x 3.3 GHz
- 8 GB RAM
- /dev/sda1 is Ubuntu, about 1400GB
- Zotac Nvidia GTX 560
- ASRock Z68 Pro3
Thank you in advance!
Andrejs Cainikovs over 10 yearsPlease provide logs from
/var/log/messages. If you are not able to log in, you can obtain them while booted via live CD.
ish over 10 years
dmesg | pastebinitplease
Eliah Kagan over 10 yearsI had originally thought that the problem here was that the kernel was not properly reinstalled. But I am not convinced this is true, and the upvotes on my answer (which provided a more detailed reinstallation procedure) made this question look answered in the questions list. So I've removed that answer, and posted it (with appropriate changes) in the question where it better belongs. Anyone who needs it can find it there. Good luck with this problem!
slashcrack over 10 yearsThe problem is that I installed the kernel but the system doesn't boot up!
JXPheonix over 10 yearsIn the future, you can remove old kernels using
sudo apt-get autoremove.
slashcrack over 10 yearsFirst, thank you for your answer. The new installation without formatting helped! Now I have got all my data from my home directory. But: All applications, all settings and all my configurations are lost. In addition to that there are many bugs and glitches with the window manager and Unity. I also tried a new installation and this worked better for me.
Michael over 9 yearsHi Psusi - I ran these commands (askubuntu.com/questions/89710/…) yesterday on a small laptop and accidentally erased my kernel. By following your instructions in this post I recovered my system in 2 minutes. If I had followed any other instructions I would still have been fighting to recover. Thanks again!
Gianluca Della Vedova over 8 yearsI can confirm these instructions works also on 14.04
mako over 8 yearsThis answer is incorrect in at least two ways: (1) It does not describe how to repair a system but rather how to backup, remove, and then reinstall your system! (2) It gets the back/reinstalling part wrong too! For reference: /usr/lib/ does not contain a list of packages and neither does /etc/alternatives. If you want a list of packages installed on your system, you can get one easily with: <code>dpkg --get-selections</code> and can restore it with <code>dpkg --set-selection</code> although on the newest version of Ubuntu getting the reinstall to work without dselect can take some effort.
mako over 8 yearsThis is correct but there are several things worth noting: (1) Your root filesystem might not be /dev/sda1. (2) The network will normally not be accessible from within the chroot if you need to download the package with apt-get. (3) If your filesystem is encrypted, not only will it likely not be /dev/sda1 but the new kernel will (having been run from the LiveCD) not include the LUKS cryptsetup tools necessarily to unencrypt your disk while booting. Fixing this is possible, but much harder.