5

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?

cl-netbox
  • 30,845
  • 7
  • 93
  • 131
Leo Simon
  • 1,519
  • 3
  • 18
  • 35
  • 1
    UEFI stores its boot info in its NVRAM. So your now motherboard knows nothing about booting anything. Most auto find the Windows entry or the hard drive/fallback entry, but not Ubuntu entry. Can you boot Windows directly from UEFI boot menu often f10 or f12? If you cannot UEFI boot flash drive then it may not be correctly configured. Check that you downloaded it correctly. Or try a different installer: http://www.ubuntu.com/download/desktop – oldfred Feb 07 '17 at 13:36

3 Answers3

12

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.

cl-netbox
  • 30,845
  • 7
  • 93
  • 131
  • Thanks for this. gnome-disk worked perfectly, so I can boot into ubuntu, and choose the try ubuntu option. I have EUFI Bios so used the first option you proposed. I got one error/warning: `EFIBOOTMGR: EFI variables are not supported in this system`. I don't know if this problem was critical, but when I restarted, I booted straight back into windows, i.e., the grub-loader didn't take over. Could you advise next steps please? – Leo Simon Feb 07 '17 at 16:09
  • @LeoSimon It looks as if you have installed the operating systems in either different modes (maybe) ... or Ubuntu in MBR (CSM) mode ... both systems have to be installed either in MBR (CSM) or UEFI mode ... also important : when you boot from the USB drive, select the USB entry with UEFI in front in case the systems are installed in EFI mode. Don't forget to disable hibernation and Fast startup in Windows before and then shutdown the PC completely - do NOT restart ! :) – cl-netbox Feb 07 '17 at 16:17
  • Fabulous, @cl-netbox, for the benefit of other people in my predicament could you perhaps edit your original answer, to specify explicitly which USB option to select when loading the iso? I tried to make this edit but didn't think I could be clear enough. There were two USB options, and I simply chose the first of them. I can imagine others might make the same mistake! – Leo Simon Feb 07 '17 at 16:34
  • Fantastic answer; you certainly saved my installation. I was confused by your `sdX`, `sdXX`, and `sdXXX` terminology, so I would add some clarification such as the following: `sdX` is the disk which is typically named in the first line of the `sudo fdisk -l` command. Examples include `sda`, or `nvme0n1`. The system partition `sdXX` should be reported as `Linux filesystem` by `fdisk`, e.g. `sda2` or `nvme0n1p2`. The EFI partition is reported as `EFI System` by `fdisk`; e.g. `sda1` or `nvme0n1p1`. – Paul Brodersen Aug 07 '18 at 16:01
  • Hi. Will this affect the windows boot entries in bios boot menu? I do not want to lose that entry. – Ejaz Feb 28 '21 at 12:20
  • Also `sudo mount /dev/sdXX /mnt/boot/efi` results in an error there is no `mnt/boot/efi` folder. I checked in `/mnt/boot` and it has a bunch of vmlinuz, memtest, initrd.img, system.map and config-****-generic files init. There is also a `grub` directory in it. Did i insall Ubuntu in some non-traditional way? BTW my windows and ubuntu are on separate disk drives. – Ejaz Feb 28 '21 at 15:11
1

This is a different answer, as I've just had the same problem.

My logic if you just replaced the MotherBoard then your hard drive (including its boot sector) should be the same so those recovery steps shouldn't be necessary.

Part A: Ensure that you have the correct boot type. Legacy / UEFI your error message above seems to imply you have the wrong one. Try changing this option

For me UEFI was the correct one.

Part B (UEFI only): In bios find your boot sequence options. Add a boot option (your bios should be similar to mine) browse until you can find the correct EFI file for grub. example:

  • Boot Option Name: grub
  • File System List: ~DID NOT CHANGE~
  • File Name: \EFI\ubuntu\grubx64.efi

Part C Choose boot order. Put your preferred boot as the first option.

Wes
  • 228
  • 1
  • 11
  • This was what was missing in all other comments I read. After changing the motherboard, following your "filename" suggestion, I simply went through all the partitions from the BIOS menu and finally found the one that had EFI folder in root, I followed the path, selected the grubx64.efi and then gave it a name. It was then added to the list of boot options in BIOS. I just moved it to the top of the list and saved the settings of BIOS ... and DONE! – Mehrad Mahmoudian Jul 29 '20 at 09:58
  • Glad it helped you. I didn't think anyone had found this useful. Its easier than installing recovery media. – Wes Jul 29 '20 at 14:49
  • Can you elaborate on "Part B" please? How do i add an option to my bios boot options? Thanks. – Ejaz Feb 28 '21 at 12:15
  • @Ejaz I'm afraid that the option location will change from BIOS to BIOS. – Wes Mar 10 '21 at 14:24
0

It seems like this kind of problem is best solved by using the Boot-Repair utility.

Its use is described here: https://help.ubuntu.com/community/Boot-Repair

Summary:

  1. Download the Boot-Repair image from here: https://sourceforge.net/projects/boot-repair-cd/
  2. Create a bootable USB stick using the image.
  3. Boot on the stick.
  4. Follow the instructions in the Boot-Repair GUI.

This probably often makes the same changes as is done manually in cl-netbox's solution. But it also performs diagnostic checks, suggests actions, and lets you save diagnostic information.

Lii
  • 53
  • 6