Linux, Operating System

Let Windows Bootloader reload GRUB2 for Ubuntu


If you use GRUB as MBR, after format Ubuntu partition GRUB will erase also.
However, after re-build Windows Bootloader as MBR, GRUB2 will be replaced, and Ubuntu cannot be started for booting.
So, how could let Windows Bootloader as MBR and boot up Ubuntu after GRUB2 is replaces.

Let Windows Bootloader reload GRUB2 for Ubuntu
Before re-build Windows Bootloader as MBR, we need to boot to Ubuntu to do some preparations.
Mount the Windows Partition, you can use Recover Ubuntu GRUB‘s instruction to mount Windows Partition.
After mount the Windows Partition, type

sudo dd if=/dev/sda of=/mnt/sda1/grubboot bs=512 count=1

in terminal
The above command:
if is the partition / harddisk where GRUB2 installed.
of is the location where does the file output to.
bs and count is a constant value for this command.
(As I know, bs is number of bytes of boot sector, you can found the source from Master boot record @ Wiki)
/mnt/sda1 is the Windows System Drive which equal to DOS environment variable – %systemdrive% in Windows (In general situation is C:)
/mnt/sda1/grubboot which means “Output the GRUB as a file and named grubboot in %systemdrive%
“grubboot” is just a filename for GRUB in general, you can rename and relocation the file as you like, but you need to locate the file for Windows’s scope.

Let Windows Bootloader reload GRUB2 for Ubuntu
Reboot the computer and switch to Windows Partition.
You can see grubboot in your %systemdrive% (C:)

notepad %systemdrive%boot.ini


notepad C:boot.ini

in System Run
Caution! If you are using Windows VISTA or Windows 7, you need to run this command with Administrator.

Let Windows Bootloader reload GRUB2 for Ubuntu
Type C:grubboot=”GRUB Boot” at the end of boot.ini.
C:grubboot is the location of GRUB file.
GRUB Boot is the description of this option in Windows Bootloader menu.
Save boot.ini and then reboot the computer.

Let Windows Bootloader reload GRUB2 for Ubuntu
Let Windows Bootloader reload GRUB2 for Ubuntu
When Windows Bootloader is loaded, you can select GRUB Boot option to switch to GRUB2 and GRUB2 also can switch to Windows Bootloader.

You can edit countdown and default boot up partition in boot.ini
timeout is the countdown, the value represent the seconds.
default is the default boot up partition if you don’t press any button on keyboard.
(For example: default=C:grubboot)

You just connect Windows Bootloader and GRUB.
You can keep to update your GRUB2 but you don’t need to know how Windows Bootloader can switch to each Non-Windows OS Partitions.
However, you need to re-build GRUB file after you update your GRUB2.