How do I resolve a GRUB: “invalid arch independent ELF magic” error?

Solution 1:

The solution for me was (and probably for anyone having that problem):

Boot into the live cd and type into the terminal (of course you must edit the mounting operations respecting your own partition table):

sudo apt-get install grub-efi-amd64
sudo mount /dev/sda3 /mnt
sudo mount /dev/sda1 /mnt/boot 
sudo grub-install --root-directory=/mnt /dev/sda

Now grubx64.efi should boot without any problems.

Running update-grub while booted into ubuntu restored the more eye friendly looks of the grub boot menu.

Solution 2:

I had the same problem “invalid arch independent ELF magic”.

I was installing from a USB stick booted from the Bios in UEFI mode.

After a couple a couple unsuccessful reinstallation of 12.04,I tried the same installation with the the USB stick booted without the UEFI mode and it works.

For your information my setting on a 120GB SSD

sda1 /windows 90 GB   windows 7
sda2 /boot  100 MB
sda5 swap     1 GB
sda6 /        18GB   ubuntu 12.04
sda7 /home     8GB

My motherboard is P8P67 Pro with Asus EZbios and I had two choice in my boot menu for the USB with 12.04 installation.

Hope it helps!