Ubuntu – Motherboard replaced – How to recover GRUB

grub2mbrunetbootin

I had a dual boot setup on my Dell laptop with Ubuntu 16.04 and Windows 10. The tech replaced the motherboard and now I'm not able to boot. I am trying to restore GRUB – I installed a version of Ubuntu 16.04 on an USB stick, following the instructions on this site. Then I tried to boot from USB, but received this message:

Missing operating system
Selected boot device failed.

Can somebody tell me how to proceed?

Best Answer

Part 1 - Creating the installation media

3rd party installation media creation tools like Unetbootin are not creating the USB installation media properly in many cases. A tool to create a correctly working installation media is GNOME Disks, it's available in the repositories of nearly every Linux distribution.

Open Disks - select Restore Disk Image from the menu on the top right.
Choose the ISO file and the USB drive to write it to, then start restoring.

In case you have no access to a Linux operating system and have to do it from within Windows, you can create the installation media with the diskpart tool from a running Windows system.

Open Command prompt as administrator and execute :

diskpart
list disk  
select disk *  
clean  
create partition primary  
active  
format fs=fat32 quick  
assign letter=**  
exit

Note : * = number of USB drive | ** = select a free drive letter
Now mount the ISO file and copy the content to the USB disk.

Part 2 - Reinstalling the GRUB boot loader

Boot from the Ubuntu installation media - select the option Try Ubuntu without installing.
Once you are on the Live desktop ... open a terminal and execute the following commands.

Important information concerning the USB boot options :

Choose the USB entry with UEFI in front, in case the systems are installed in EFI mode and
the USB entry without UEFI in front, in case the systems are installed in legacy BIOS mode.

In case your computer has UEFI BIOS execute these commands :

sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub  
exit

Note : sdX = disk | sdXX = EFI partition | sdXXX = system partition

In case your computer has legacy BIOS execute these commands :

sudo mount /dev/sdXX /mnt  
sudo grub-install --boot-directory=/mnt/boot /dev/sdX  
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done  
sudo chroot /mnt  
update-grub
exit  

Note : sdX = disk | sdXX = system partition

You can identify disk and partition numbers by using GParted (included in the installation media).

Additional information : Do not forget to disable hibernation and Fast startup in Windows !
Then shutdown the PC completely, do NOT restart - otherwise it will always start Windows.

Related Question