# Surface Pro 3 Grub Boot

How to install grub2 in efi after it failed to install it automatically

1. Boot into Ubuntu LiveCD

2. Open a Terminal, access sudo
3. 	```
	modprobe efivars
	``` 

4. 
   Mount the installed ubuntu partition on /mnt 
   ```
   mount /dev/sdaX /mnt
   for i in /dev /dev/pts /proc /sys; do mount --bind $i /mnt$i; done
   ```
   Mount the efi partition in the ubuntu system partition  
   ```
   mount /dev/sdaX /mnt/boot/efi
   ```
   
5. Chroot into mnt
	chroot /mnt
	
6. 
	Check if you got access to the efi boot manager entries  
	```
    efibootmgr -v
    ```
	**If you get errors like Input/Output error for Boot0003 or so you have to enter the entries manually later.** 
	
7. install grub:
	```
	apt-get update && apt-get install --reinstall grub-efi
	grub-install 
	update-grub
	```
    
	**If you got no error you should be done.**   
	**If you got an error on efibootmgr before you are NOT done.**
	
8. Open another terminal with sudo access

9. 	Look up all boot entries with 
	```
    efibootmgr -v
    ```
	delete all unused entries with 
    ```
    efibootmgr -b <X> -B
    ```  
	
    * -b X defines the Boot000X number 
    * -B removes

10. Àdd the boot entry for your system  
	```
    efibootmgr -c -d /dev/sda -p X -L "BootEntryName" -l "\efi\ubuntu\grubx64.efi"
    ```
	* -c creates new entry -d is the disk -p is the sdaX entry of the EFI partition
	* -L is the shown Name on the Grub Loader -l is the path on the EFI Partition to the loader
	
    on ubuntu it **SHOULD BE** `\efi\ubuntu\grubx64.efi` but verify first!  
	**YES BACKSLASHES NEEDED**