Installing Grub fails on Ubuntu 16.04

I got this nasty error when it came to having a fresh install of Ubuntu 16.04. It says that GRUB cannot be installed on /target device. In order to fix this you need to:

  1. Create a partition around 300 mbs
  2. Use the FAT32 format and target it as EFI partition
  3. Choose that the GRUB installer should be installed on this 300 mbs partition

Then the installation should finish succesfully without any errors.