Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running Ubuntu 12.04 LTS LAMP server, and it won't boot. This problem started when I was trying to clean up /root and accidentally deleted all of the kernels using apt-get remove. I was able to restore the latest kernel, but now I get "ELF Header Smaller Than Expected" when I try to boot from the hard drive. This system has a 2 TB drive, so it uses LVM. I restored the kernel by using the instructions on this page How to restore a system after accidentally removing all kernels? but I also had to use the instructions on this page in order to mount the file system using LVM2 and do a chroot:

After restoring the kernel and getting the grub error, I tried using I booted from the live CD, mounted the file system, chrooted to it, and installed and ran Boot-Repair. That didn't solve the problem.

I also tried doing this while chrooted to the file system:

rm -rf /boot/grub/*
apt-get install grub    
grub-install /dev/sda
update-initramfs -c -k all

The problem persists. What do you need to see to help me solve the problem?

Update Here's the information from boot-repair:
share|improve this question

You did the worst possible approach trying to fix the system, you removed the kernels along with everything that allowed you to boot and to make things better that wouldn't have fixed your ELF problem. If you have internet in the chroot environment do the following:

sudo apt-get install debsums
debsums -s

This will produce a list of packages. Do the following with all of them:

sudo apt-get --reinstall install package1 package2 package3

Once you have done this, repair your GRUB:

sudo apt-get purge grub-common grub-gfxpayload-lists grub-pc grub-pc-bin grub2-common
sudo apt-get install grub-common grub-gfxpayload-lists grub-pc grub-pc-bin grub2-common

From there we could try to fix your ELF problem.

share|improve this answer
Thanks @Braiam I appreciate your help. A clarification. When you said I used the worst possible approach trying to fix the system, are you referring to using apt-get remove to remove old kernels? Would it be a better approach in the future to just rm them? I'm not a linux expert, as you've guessed. Also, I don't understand your fix. I mean I understand what you said to do, but you say it won't fix my ELF problem. AFAIK, that's my problem. Sorry, I'm not questioning your expertise. I'm just trying to understand. – user217202 Nov 21 '13 at 4:57
I just performed the suggested procedure. It took about 3 hours, and my system still won't boot. – user217202 Nov 21 '13 at 8:40
@user217202 rm should be always the last resource when repairing stuff, and in this case is very likely that it did nothing. The ELF error has little to do with GRUB and more with the kernel. When removing things that were installed the safest and complete solution is using APT tools. Yes, apt-get remove is thousands times better to really remove installed files. No, if you rm them for APT it will still be installed and will expect to find them. Your ELF error apparently is not easy to fix and requires wits to figure out (nobody in the community knows why it happens). – Braiam Nov 21 '13 at 13:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.