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

This question already has an answer here:

I've got a brand new laptop with a 128GB SSD drive. I read that aligning the partitions to match the Erase Block Size of the SSD is important. I followed William Scott's guide SSD Tweaks in Linux and Aligning Partitions and my partitions ended up being:

$ sudo fdisk -lu /dev/sda

Disk /dev/sda: 128.0 GB, 128035676100 bytes
32 heads, 32 sectors/track, 244208 cylinders, total 250069680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00037bd2

   Device Boot       Start        End     Blocks   Id  System
/dev/sda1   *         1024     206847     102912   83  Linux
/dev/sda2           206848   16985087    8389120   82  Linux swap / Solaris
/dev/sda3         16985088  250068991  116541952   83  Linux

Then I installed Ubuntu Natty and specified the partitions manually so that /dev/sda1 became the /boot partition formatted with ext2, /dev/sda2 the swap and /dev/sda3 the / formatted with ext4. After the installation the thing didn't boot, and I ended up in the grub-rescue console which doesn't make any sense to me. It's giving me:

error: invalid arch independent ELF magic.
grub rescue>

Have I done some mistakes during my installation? How do I solve the issue with grub-recovery?

share|improve this question

marked as duplicate by Jorge Castro, Eric Carvalho, Aditya, Warren Hill, BuZZ-dEE Jan 22 '14 at 20:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

can you seperate the answer from your question? – Lekensteyn Apr 29 '11 at 6:02
I will, I'm currently reinstalling the OS to verify the solution. – hleinone Apr 29 '11 at 6:14
Sigh... the installer should just do this automatically or at least make it a preseed switch. – ppetraki Apr 26 '12 at 13:40
up vote 9 down vote accepted

Boot into Live CD and run:

sudo mount /dev/sda3 /mnt
sudo mount /dev/sda1 /mnt/boot
sudo grub-install --root-directory=/mnt /dev/sda
share|improve this answer
For EFI machines, you'll need to install grub-efi while booted in the live-CD, otherwise you'll get some puzzling errors. – CraigM Jul 19 '11 at 4:04
Just want to point out that --boot-directory (b instead of r) as written elsewhere does not work. Just got kicked into a different looking grub shell. – l0b0 Jun 22 '12 at 9:52

I have fixed the same problem with Backtrack , on VMware. The boot was broken after installing vmware tools

I used the following commands to fix it:

sudo mount /dev/sda1 /mnt
sudo grub-install --root-directory=/mnt /dev/sda
share|improve this answer

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