Thursday, March 17, 2016

Dual Boot Windows and Ubuntu, Grub Problem



I'm a linux novice trying to get a windows/ubuntu dual boot working. I can access both OSs ok, but only by navigating through a series of strange BIOS menus for Ubuntu (Windows boots automatically). Grub does not start initially, which is what I'm trying to fix.




I've successfully partitioned my drive for Windows 7 Home Premium and Ubuntu 14.04.1 LTS. I have a HP-250 G1 laptop.



I installed Windows first (on a 200 GB partition), then gave the rest of my drive to Ubuntu (500 Gb, ext4). I made partitions for swap (6500Mb) and biosgrub (1 Mb) when installing Ubuntu.



When I start my laptop, Windows boots automatically, without giving any options for Ubuntu. The only way to boot Ubuntu is to restart the computer, open the Startup Menu, go to Boot Device Options and choose ubuntu (TOSHIBA MQ01ABD075), which starts grub and allows me to boot into Ubuntu.



I have tried using EasyBCD to get the Windows Bootloader to recognise Ubuntu, but I get an error along the lines of Failed to initialize properly. Annoyingly, the Windows Bootloader always pops up now, even if I delete the Ubuntu pointer.



I have tried to use the Ubuntu Boot-Repair, the output was this http://paste.ubuntu.com/9604542/




I tried entering the following command into an administrator command prompt bcdedit/set{bootmgr}path\EFI\ubuntu\shimx64.efi as recommended by the boot-repair, but complains An unknown command was specified (EDIT)



So, long story short, I'd just like grub to start up when I boot up my laptop. Any help would be really appreciated!!



I will try to answer my own question. Apologies if my use of technical terminology is wrong. Aim: To get Ubuntu to boot as default, and allow me to boot Windows by playing with BIOS.



I believe the problem is the EFI on my machine does not allow me to boot from anything but /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi, see here for a discussion of this. The following is a work-around for users who mainly use Ubuntu, but sometimes want to boot into Windows. My expectation is that this is mainly of relevance to HP-users, from accounts on the internet.



1) Install Windows, and then Ubuntu, see here




2) Restart the computer. If windows automatically boots then try using efibootmgr to give Ubuntu precedence, see here. If this works, you're done so stop reading.



3) If your computer is like mine, no matter what you do in efibootmgr, Windows will always force itself first. Changes you make will be undone when you restart the computer. In this case, the following hacks work for me.



4) Restart your computer, quickly press esc and go into the Boot Manager. There should be an option to start Ubuntu, choose that and launch Ubuntu.



5) Start a console and backup the important bootmgfw.efi to allow a boot to Windows



$ sudo -s
# cd /boot/efi/EFI/Microsoft/Boot

# cp bootmgfw.efi ./..


6) Create a new boot number, so we can boot up Windows in a hacky way by linking to the backup of bootmgfw.efi we just made. Run



# efibootmgr -c -L "Windows_2" -l "\EFI\Microsoft\bootmgfw.efi"
# efibootmgr -v


Use the last command to check the new entry was made. At this point I recommend you restart the PC and check booting into Windows_2 does indeed boot Windows. After you've done that, boot Ubuntu and cd back into /boot/efi/EFI/Microsoft/Boot




7) Renaming grubx64.efi to bootmgfw.efi allows us to boot Ubuntu first. Now enter the following commands:



# cp ../../ubuntu/grubx64.efi .
# cp bootmgfw.efi bootmgfw_backup.efi
# rm bootmgfw.efi
# cp grubx64.efi bootmgfw.efi


This should now work. Restart your machine.




Expected behaviour: Upon booting the PC, grub should open up as the default, allowing you to launch Ubuntu. Trying to launch Windows from grub will just link you back to grub in a never-ending loop. To launch windows, you must restart the computer, quickly press esc and go into the Boot Manager. Select Windows_2 and that will launch windows.



Hacky but it works so far. I will update the post if it turns out this ruins my computer.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...