I have recently dual-booted a Windows PC with Debian Wheezy. The installation went fine with no errors, but when I boot to Debian I am immediately greeted with GRUB rescue:
Welcome to GRUB!
error: unknown filesystem.
Entering rescue mode...
After examining further using the set
command I notice that it is booting to the wrong partition:
grub rescue> set
prefix=(hd0,gpt4)/boot/grub
root=hd0,gpt4
Here it is pointing to (hd0,gpt4)
when the location Debian is installed to is (hd0,gpt5)
. So, I did a quick fix using set
to change the variables back to what they should be:
grub rescue> set prefix=(hd0,gpt5)/boot/grub
grub rescue> set root=gd0,gpt5
After doing this, I did only what I remembered I should do to boot to the OS and ran:
grub rescue> insmod normal
This is where things start to go wrong as I get the error:
error: invalid arch independent ELF magic.
I then did some research on this problem and it seemed the common solution was to reinstall GRUB from a live CD. So, I booted into a live CD of Debian and ran the following:
sudo mount /dev/sda5 /mnt
sudo grub-install --root-directory=/mnt /dev/sda
Where I am given the error:
The file /mnt/boot/grub/stage1 not read correctly.
Although I can assure that this file does exist and is editable as I could edit it with
sudo nano /mnt/boot/grub/stage1
So what could be the problem?
It turns out the answer was simple, I needed to install the grub-efi
package:
sudo apt-get install grub-efi