James John – Software Engineer

How to Fix Failed GRUB Installation – Install Manually

Installation of a new system I faced an error on Grub installation, all I had to do was to skip the grub installation while having the main root system installed in the drive. An example of an error like this:

11958039_1025959144094610_6566291308482556001_oSkip the grub installation and finish other installation parts, now we are going to boot in your system manually by manually configuring grub. Boot again from Live CD hit e to edit grub immediately it boots on and you have something like this

grub>

First we’d set the pager to page long output commands by typeing

grub>set pager=1

Now lets list out the available Hard disk partitions that GRUB can see

grub>ls
(hd0,gpt1) (hd0,gpt2) (hd0,gpt3)

Lets take (hd0,gpt2) as our partition where the Linux without GRUB is installed and run

grub>ls (hd0,2)/
lost+found/ bin/ boot/ cdrom/ dev/ etc/ home/ lib/ lib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/ srv/ sys/ tmp/ usr/ var/ vmlinuz initrd.img

Notice we have /vmlinuz and initrd.img in the root of the partition? Some systems might put them in /boot in case you don’t find them in the root, these are the files needed for your system’s boot up, lets continue to manually set GRUB to boot from those files

grub>set root=(hd0,2)
grub> linux /vmlinuz root=/dev/sda2
grub> initrd /initrd.img
grub> boot

Your system should boot in, now we are going to fix the GRUB installation. Open your terminal and type

$ sudo grub-install /dev/sda

Now this might be the error you get:

Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.

Find your MBR partiton in your HDD…mine is /dev/sda1 so I mount it in /mnt

$ sudo mount /dev/sda1 /mnt
$ ls /mnt
EFI  grub  mach_kernel  System

So I now rerun grub-install with this parameter

$ sudo grub-install --efi-directory=/mnt/EFI/ /dev/sda
Installing for  x86_64-efi platform.
Installation finished. No error reported.

Reboot and see your PC boot 🙂 I used this to fix my Debian 8 boot issue 🙂

James John

Software Engineer