Restore Grub / Grub 2.0 in absence of Ubuntu installation media

For the background,

Grub is Ubuntu's boot loader. On dual boot machines (e.g. Windows & Ubuntu), Grub takes care of providing User an option to boot in one of the OS.

Grub can be overwritten by Windows loader (e.g. during Windows installation), and Windows does not give option to boot in any other OS, except its own :(

The easiest method is to use boot-repair from Ubuntu to fix the boot entries post Windows installation. However, this requires a Live CD or equivalent (ubuntu usb boot etc.) to work. How this works is out of scope for this post. You can find more information on http://www.howtogeek.com/114884/how-to-repair-grub2-when-ubuntu-wont-boot/

If you happen to be in my situation, i.e. without Ubuntu installation media, you need to do few other steps. This works only when your other operating system is Windows, and at least Windows Vista or above (7, 8, 10 etc.). We will use Windows tool, bcdedit to do these steps. bcdedit lists and manages the boot entries. You can do a lot of customizations with this tool, which is out of scope for this post. You can find more information on https://www.sevenforums.com/tutorials/2676-bcdedit-how-use.html

#run windows cli with "Run as administrator" privileges
puneet-lt> cmd (right click -> Run as administrator)

#query list of current boot entries
puneet-lt> bcdedit /enum firmware

#backup current bcdfile
puneet-lt> bcdedit /export c:\savedbcd
-- if required, backup can be restored by issuing bcdedit /import c:\savedbcd

#create a new boot entry off {bootmgr} entry 
puneet-lt> bcdedit /copy {bootmgr} /d "New Windows Boot Manager"

#above command will return an identifier, e.g. {5c21820f-e04b-11ed-b770-00195b61617b}. Use this identifier to edit the new boot entry, and point to the ubuntu firmware
puneet-lt> bcdedit /set {5c21820f-e04b-11ed-b770-00195b61617b} path \EFI\ubuntu\shimx64.efi

After above all is done, restart your computer. You should now have Grub / Grub 2.0 restored. 

Comments

Popular posts from this blog

504 Gateway Timeout on Amazon AWS ELB (Elastic Load Balancer)

AWS RDS incompatible-parameters solved

Push Notifications to iOS not received from Amazon SNS