Restore EFI boot partition (Ubuntu)

When playing with USB devices I locked myself out of the ability to enter BIOS settings by disabling USB legacy support. This meant I’d have to use a PS/2 keyboard but none was available. In order to get back to BIOS I had to clear the CMOS memory on the motherboard. All went fine until I realised that the boot record for my SSD drive was cleared too and the system did not recognise my newly installed OS. Hope the following steps and links help others in the same situation:

Restoring EFI

  1. Boot an installation USB drive. The important choice here was to choose “EFI boot” option when choosing a drive to boot from (F11). Otherwise EFI is not recognised in the OS.
  2. Create EFI Boot record
    I found details on stackexhange:

    efibootmgr -c -d /dev/yourHD -p ESP_PartionNumber -L "Boot Title" -l '\\EFI\\DIST\\grubx64.efi' -u "root=/dev/yourRootFS"
    

    which in my case looked like this:

    efibootmgr -c -d /dev/sda -p 1 -L “ubuntu” -l '\\EFI\\ubuntu\\grubx64.efi' -u "root=/dev/sda6”
    
  3. Install grub
    Details and further information on askubuntu:

    sudo -i
    mount /dev/sda6 /mnt
    mount /dev/sda1 /mnt/boot/efi
    for i in dev dev/pts proc sys sys/firmware; do mount --bind /$i /mnt/$i; done
    chroot /mnt
    grub-install --efi-directory=/boot/efi
    

Leave a Reply

Your email address will not be published. Required fields are marked *