1

I know someone who has just installed Ubuntu onto a harddrive which already had Windows 10 as the main operating system. Now there is the option on startup via Grub to either boot Windows or Linux.

I'm trying to understand how this is possible.

My understanding : When the computer starts, the bios or uefi first executes, then the MBR code which will examine the partition table to see what to boot. When only Windows is installed, Windows automatically boots.

When installing Linux / Ubuntu on top of this, where does the bootloader / grub get installed so that the MBR knows to execute this instead of just Windows?

3

When installing Linux / Ubuntu on top of this, where does the bootloader / grub get installed so that the MBR knows to execute this instead of just Windows?

When you install GRUB on BIOS systems, it completely replaces the original MBR bootcode with its own. Later, when you select "Windows" from the boot menu, it does mostly same thing the original MBR bootcode would have done.

Windows uses a traditional MBR which is very generic – all it does is look for the 'active' partition and execute its VBR sector. So GRUB doesn't actually need the original MBR at all – when you choose the "Windows" item in GRUB, it just directly loads the Windows partition's VBR.

(Meanwhile, the GRUB MBR is a complete opposite – it doesn't care about partitions and always loads the remainder of GRUB core from a reserved disk area.)


Note that most new computers do not use an MBR – they have UEFI firmware which stores all bootloaders as ordinary *.efi files in the "EFI system partition". These are very similar to .exe files, and the firmware keeps its own boot menu (a list of .efi files to try).

So when you install GRUB on an UEFI system, it copies its files to the EFI system partition alongside Windows bootloader files, then inserts itself as the topmost entry in the EFI boot menu (with a higher priority than the old Windows entry).

Later, when you select "Windows" from the GRUB menu, it again doesn't do anything special – it just starts the same original Windows Bootmgfw.efi file that's still on the EFI system partition.

|improve this answer|||||
0

MBR (aka boot sector) tells the computer how the hard drives are partitioned. When installing ubuntu on top of Windows, you must inevitably create new partitions. Grub will be installed in one of them. MBR will recognize these partitions (no matter "where" they are) and give you the option to boot from the available ones.

I'm not sure if I answered what you were looking for. If you're trying to achieve something specific, please update your question.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.