Ubuntu – “grub-install /dev/sda failed” for dual-boot with Windows 10

bootdual-bootgrub2uefiwindows 10

I've tried many things in previous threads, including every suggestion in (I receive the error 'grub-install /dev/sda failed' while attempting to install Ubuntu as the computer's only OS.).

I'm a first timer (obvy). I want to dual boot with Windows 10. It's a Dell machine with some mysterious partitions. Originally I installed Ubuntu 16.04.2 successfully, but with legacy on in BIOS/UEFI. Learned that I'd have to go into 'bios' each time I wanted to run it.

Attempt to reinstall with legacy off, repeatedly get
executing grub-install /dev/sda failed

Boot-repair throws an error too, with the txt file apparently having some invalid characters – pastebin.

Boot-repair error says:

If your computer reboots directly into Windows, [which it does] 
try to change the boot order in your BIOS.
If your BIOS does not allow to change the boot order, [which it doesn't, at least it doesn't provide an Ubuntu option]  
change the default boot entry of the Windows bootloader. [which looks way too advanced for me]. 

Ideally I want to choose which OS to launch on boot.

Something's not right here, but I've tried:

  • Running ubuntu live USB and then launching from desktop.
  • Multiple attempts to manually create partitions (with /boot partitions in both EFI and FAT32 formats, and none at all using this guide How to use manual partitioning during installation?)
  • Multiple attempts using the replace existing Ubuntu installation option.

Always the same grub-install error. Assume it's something to do with the original legacy-enabled install and, erm, me. Partitions after my latest failed attempt are thus (I manually created partitions from sda7+).

I have NO idea where to from here.

Best Answer

I ended up fixing it by re-installing in Legacy mode (successfully) and manually install grub-efi by doing the following from Can I install in UEFI mode with the alternate installer?

After the installation, reboot the computer into a live CD or any Linux CD that can mount the hard drive partitions. Then, do the following: (replace # with appropriate partition numbers)

### Mounting ###

sudo mount /dev/sda# /mnt            #Mount root (/) partition
sudo mount /dev/sda# /mnt/boot       #Mount boot (/boot) partition 
                                      (if separate from root partition)
sudo mkdir -p /mnt/boot/efi          #Create EFI partition mount point
sudo mount /dev/sda1 /mnt/boot/efi   #Mount EFI partition

sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

sudo chroot /mnt                     #Chroot to your installation

### Installing ###

apt-get install grub-efi-amd64  #Install grub EFI bootloader

grub-install --recheck --no-floppy --force
                                     #Install grub bootloader in EFI partition

echo "configfile (hd0,gpt#)/boot/grub.cfg" > /boot/efi/ubuntu/grub.cfg
                                     #Tell grub to load grub.cfg from /boot

update-grub                          #Create grub menu list

exit                                 #Exit chroot

### Unmounting ###

sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt/boot/efi
sudo umount /mnt/boot
sudo umount /mnt
Related Question