View Full Version : error: invalid arch independent ELF magic

December 12th, 2012, 12:52 AM
I've been running Ubuntu on my Lenovo ThinkPad for the last several months as a second partition alongside the original Windows 7 installation.

Two things happened before I started having problems that I think might be related:

*I had to interrupt an upgrade process when it was trying to upgrade the the most recent version of Ubuntu.
*The computer went to sleep and experienced a graphics bug when I tried to wake it up. I had to reboot by holding down the power button.

For a while I was just getting a blank screen with a cursor, so I booted from a USB with boot-repair. I clicked 'Try Ubuntu' after booting from the USB and ran the boot repair utility. It seemed to be successful and gave me the following link:


Now when I try to boot to the Ubuntu partition I get:

error: invalid arch independent ELF magic
grub rescue>

That's got to be the most amusing error message ever. But, anyone know what I can do to fix this?

Thanks in advance!

December 12th, 2012, 01:32 AM
In this thread, they just reinstalled grub to the MBR.

Edit missed link:

Is your system BIOS/MBR as the follow up posts may not have been and UEFI/gpt is a lot different.

Post the link to the BootInfo report that this creates. Is part of Boot-Repair:
Boot Repair -Also handles LVM, GPT, separate /boot and UEFI dual boot.:
You can repair many boot issues with this or 'Create BootInfo' report (Other Options) & post the link it creates, so we can see your exact configuration and diagnose advanced problems.
Install in Ubuntu liveCD or USB or Full RepairCD with Boot-Repair (for newer computers)

December 12th, 2012, 02:38 AM
I thought I did post the link from the boot repair.

I'm having trouble making sense of your post. Do you have a recommended course of action or need more info?

December 12th, 2012, 05:35 AM
I meant to include a link where they just reinstall grub to the MBR. Added to my first post.

Did you use Boot-Repair to reinstall grub? It looks like you did, but then do you still get error?

December 12th, 2012, 08:49 PM
Thanks for the replies, oldfred, now I'm making progress!

When I try this command

sudo mount /dev/sda5 /mnt
in the terminal I get this error message:

mount: can't find /dev/sda5/mnt in /etc/fstab or /etc/mtab

Looks to me like it's somehow looking in the wrong place for the bootable drive?

Yes, I when I ran the boot-repair utility one of the steps it reported taking was reinstalling grub.

December 12th, 2012, 09:32 PM
sudo mount /dev/sda5 /mnt

What you posted is missing the space after the 5? Best to copy & paste commands if at all possible. Some spaces may not look like spaces.

December 12th, 2012, 09:47 PM
Newbie alert! Thanks, now it makes sense why that space is there.

I got the grub prompt now. I bet I can figure out from here how to get it to give me the nice boot menu so I can choose my OS. I'll let you know if I run into problems.

Thanks again!

December 12th, 2012, 10:24 PM
If you are just at grub? or still grub rescue? It may not be easy.

Commands to manually boot.
Grub Rescue Prompt Megathread - drs305
HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

December 12th, 2012, 10:32 PM
Just at grub> now. No more grub rescue.

December 12th, 2012, 10:53 PM
You can try manual boot commands as link to above.

You might just try boot repair again, but run the full grub uninstall/reinstall. Just make sure you have working Internet as it has to redown load a new copy of grub to reinstall it.

December 12th, 2012, 11:06 PM
I tried running the boot repair utility again.

Then I tried following the nice instructions here: http://howtoubuntu.org/how-to-repairrestorereinstall-grub-2-with-a-ubuntu-live-cd/

Still getting a grub> prompt instead of a boot menu.

Haven't been able to figure out (yet) which sequence of manual commands I need to boot directly from the grub> prompt.

December 13th, 2012, 01:08 AM
Did you do the full install & reinstall. When I went to post commands below I noticed you are missing the link to the initrd.img in root

Normal using the links in root, but script does not show initrd.img:
set prefix=(hd0,5)/boot/grub
set root=(hd0,5)
linux (hd0,5)/vmlinuz root=/dev/sda5 ro
initrd (hd0,5)/initrd.img

This may work, but if grub was not fullly configured?

set prefix=(hd0,5)/boot/grub
set root=(hd0,5)
linux (hd0,5)boot/vmlinuz-3.0.0-21-generic root=/dev/sda5 ro
initrd (hd0,5)/boot/initrd.img-3.0.0-21-generic

Another is the older -15 kernel. Change all the -21 to -15 to see if older version still works.

December 14th, 2012, 01:31 AM
All of the variations I try of third line beginning with 'linux' give me the following error:

error: file '/boot/grub/i386-pc/linux.mod' not found

Will investigate this error with my own google searches, but thought I'd post it here since you've been so helpful :)

December 14th, 2012, 05:45 AM
Your boot script showed grub2 1.99 in MBR. But it is grub2 2.00 that now has all the mod files in another sub-directory i386-pc. Or versions do not match.

So did you reinstall grub with a newer version of Ubuntu. Ubuntu now seems to require you to use the same version for consistency.

Or from Boot-Repair use it to chroot and totally uninstall and reinstall grub2 from inside your install to you have version consistency.

To chroot, you need the same 32bit or 64 bit kernel. Best to use same version.
drs305 chroot to purge & reinstall grub2
kansasnoob- full chroot one line version with &&---- change sda3 to your install

December 14th, 2012, 05:55 AM
The version of Ubuntu I used to make my bootable usb and run the boot-repair was newer than my original Ubuntu install. Is that what you're thinking is causing the problem? I installed a newer version of grub and it's trying to boot to an older version of Ubuntu?

So uninstalling and re-installing grub might help, you seem to be saying. I'll try to do that and I'll sort through your links. Thanks again for the continued help.

December 19th, 2012, 02:51 AM
I went ahead and just reinstalled Ubuntu as I didn't really have anything worth saving in my old install. Thanks again for the help!