Where should you install GRUB?

When you are installing Linux, regardless of which distribution you choose, one question is always the same. How do you boot your system?

You’ll invariably be presented with two options for installing GRUB, the Grand Unified Bootloader. This is the tiny piece of software responsible for starting up your computer and getting Linux — or Windows, if you dual-boot — loaded into memory. Because the PC architecture has undergone dramatic changes in the last 25 years, the boot process has become more complicated, and requires a small piece of software to handle getting your chosen operating system loaded into memory.

With Windows XP, this piece of software is called NTLDR. On Linux, it’s called GRUB. (There was also another bootloader called LILO, but it’s been obsolete for years and is not recommended for new installations, even if your distribution gives you the option.) Both of them do the same thing: they get the operating system loaded into memory, and optionally, present you a menu with different choices on how you would like to boot your system.

As I mentioned, there are two options for installing GRUB. First, you can install it to the Master Boot Record of your first hard drive. Second, you can install it to the boot sector of the active (bootable) hard drive partition. Which one is the right one? It depends.

If you intend to dual-boot Windows, then you should avoid installing GRUB to the MBR. The reason for this is that Windows occasionally overwrites the MBR, for instance, when you reinstall it, and that could be quite often. When that happens, your Linux system will seem to disappear as your system starts booting directly into Windows, bypassing the boot menu altogether. To avoid this, install GRUB to the boot sector of the active partition instead.

There’s an exception to that rule: If you are installing Linux to a secondary hard drive, and no part of it will be on your main hard drive, then you must install GRUB to the MBR, and take your chances with Windows overwriting the MBR with its own at some future date. If this happens, you’ll have to use a Linux rescue CD to get GRUB reinstalled. (I’ll cover this procedure in the future.)

If, however, Linux will be the only operating system on your computer, it’s perfectly safe to — and you must — install GRUB to the MBR.

Some special circumstance notes: If you run OS/2, you MUST NOT install GRUB to the MBR under any circumstances, or you won’t be able to boot OS/2! You will have to install it to the boot sector of the Linux /boot partition on your primary (first) hard drive. If you don’t have any free unpartitioned space on your first hard drive, you will have to use a resizing tool such as Partition Magic to create some space and have your Linux installation create the Linux /boot partition in that space. The space must be within the first 1024 cylinders of the hard drive. And it will have to be a primary partition as well, not a logical partition. Many computers can’t boot from logical partitions, only primary ones. The root (/) partition can be elsewhere, even on a secondary hard drive. You’ll then need to add the /boot partition to OS/2’s Boot Manager menu once you’ve completed the Linux installation.

If you have multiple Windows versions on your computer, and use a Windows boot menu to access them, you can add Linux to the Windows boot menu, but the process for this is somewhat complex, and I don’t intend to cover it here. Install GRUB to the boot sector instead, creating a /boot partition on the primary hard drive if necessary (see the OS/2 note above).

As you’ve probably gathered, the simple everyday act of booting up your PC is much more complex than you thought it was. This has a lot to do with the way your computer’s BIOS accesses internal hard drives. The BIOS is the very first bit of software which starts when you turn on your computer, and it’s located on a physical ROM chip inside the machine.

Twenty years ago, hard drives of 5 to 20 MB were common, and many PCs even shipped without a hard drive! Even as late as ten years ago, most computer BIOS software could not access more than the first 528 MB of a hard drive, creating booting problems. Eventually a solution called LBA (logical block addressing) raised this limit, first to 8 GB, and in more recent computers, to 137 GB. This is the range that the so-called first 1024 cylinders can access through the BIOS, before your operating system loads (using GRUB, NTLDR, or what have you). As hard drives exceed 137 GB now, and computers with 1TB of hard drive space are just now becoming available to consumers, the 20 year old BIOS design will again make trouble for the seemingly simple task of starting your computer.

One thought on “Where should you install GRUB?

  • July 13, 2013 at 4:48 am
    Permalink

    great. this article give me a idea for what I must to do. Thank’s.

Comments are closed.