Sunday, October 19, 2014

linux - Repair Ubuntu boot loader from Windows




My windows 8 is installed on the C drive. I installed ubuntu on the D drive. By mistake I chose the boot loader to load from the C drive while installing ubuntu.
Then, restarted and it directly booted into ubuntu without giving me the option to choose from the OS list. Then, I repaired the windows loader from ubuntu using the following command:



sudo apt-get update; sudo apt-get install syslinux


then



sudo dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda



now, it directly boots into Windows only! The problem is reversed!



Question is how to have a boot loader option to choose from, to boot into the desired OS.
Thanks



Last Update



I removed those unncessary disks and reinstalled the ubuntu. but it is the same story!

I have 120GB SSD on the Port0 containing my windows 8 and a disk of
500GB in the Port1 on which I installed ubuntu and 2TB disk in Port2. Plus a USB stick of 8GB which I used to boot-repair for.
Here is report uploaded to:
http://paste.ubuntu.com/15503838/



By the way, I can reinstall the ubuntu, if need be, or if an easier solution can be found by doing so. But unfortunately i can't touch the windows OS.
I spent all my day on this boot issue, but no success, this is so complicated for me only when it comes to separate harddrives, I have it running on my laptop, on one drive which has two partitions. Working like a charm! But since the desktop has multiple hard drives, it gets complicated.
I would appreciate your help on this.


Answer



Well apparently your Ubuntu is installed on a separate disk (sdg), and since you picked the Windows disk (sda I assume), the boot code of grub is installed to its MBR, and then you replaced it with syslinux's boot code. which look for active partition and end up loading bootmgr.




So you need to reinstall grub on sdg (with Ubuntu live medium):



mount /dev/sdg1 /mnt
grub-install --boot-directory /mnt/boot /dev/sdg


You can just leave the Windows drive as the prioritized drive in your BIOS and switch to Ubuntu with your BIOS boot menu when desired.



If you prefer to use grub to switch between, prioritize the Ubuntu drive in BIOS setting, and add boot entry for the Windows:





GRUB_DISABLE_OS_PROBER=true



This entry is used to prevent GRUB from adding the results of os-prober to the menu. A value of "true" disables the os-prober check
of other partitions for operating systems, including Windows, Linux,
OSX and Hurd, during execution of the update-grub command.




(https://help.ubuntu.com/community/Grub2/Setup)




So make sure the option is false in /etc/default/grub, make sure os-prober is installed with apt-get, and then run update-grub.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...