Boot loader Grub: how to repair, adapt or remove it


Back to the home page


Introduction

1. Grub, or the Grand Unified Bootloader, is the most common boot loader for Linux. That's well deserved: the thing actually boots all conceivable operating systems. All Linux distributions, all types of Windows, all types of DOS, all kinds of BSD, Apple Mac OS, you name it. It's a small miracle of technology.

On my multiple boot laptop there once were 10 different operating systems in the menu of Grub: they all lived brotherly side by side on the same hard drive ....

Grub is evidence of the strength of simplicity: the program is very simple, but also powerful and versatile.

Yet you can occasionally come across a problem with Grub. Here you'll find solutions for the two most common problems: how to repair it and how to remove it. Plus some tips for adapting it.

Repair Grub for BIOS (e.g. because the Windows DVD has overwritten Grub)

2. First the explanation, then the how-to.

Explanation

2.1. If you install Linux first and Windows afterwards, then you lose Grub. So it's better when you install Windows first and then Linux..... Also, Grub might not successfully be installed when installing Ubuntu or Linux Mint.

Fortunately, it's an easy problem to solve. However, it's very important that you follow the instructions exactly.

Grub consists of two parts.
First, the main part of the program itself, which is placed in the Master Boot Record (MBR). The Master Boot Record is the first sector of the hard disk.

Secondly, there's the Grub boot menu with the various operating systems, plus some supporting files. These are not in the MBR, but in a folder on the active Linux partition.

Do you have two physical hard disks in your computer? Then it's important for you to know that Grub always resides in the MBR of the first hard disk. The first hard disk is the hard disk that's number 1 in the boot priority (boot sequence) in the BIOS of your computer.

If you restore (repair) Grub in the MBR, then you must again tell Grub where it can find the existing boot menu.

How-to

2.2. Note: this how-to is only fit for motherboards that run on a conventional old-fashioned BIOS. This usually means a computer that was sold with Windows Vista or Windows XP pre-installed on it.

The how-to is also fit for a motherboard that runs on an (U)EFI that has been configured to behave as if it were a conventional old-fashioned BIOS. This is normally the case for a computer that was sold with a pre-installed Windows 7.

But this how-to is definitely unfit for motherboards that run on UEFI in full UEFI mode. This is usually the case for computers that were sold with a pre-installed Windows 8.x or 10.

The how-to for Grub on (U)EFI in full UEFI mode can be found here.


Note: the how-to mentions only Ubuntu and not Linux Mint. But it's fit for Linux Mint as well: the how-to is the same for both Linux editions.

Repair Grub like this, for example when a consecutive installation of Windows has wiped Grub:

a. Boot your computer from the Ubuntu DVD (of from a Live USB with Ubuntu on it). Select "Try Ubuntu".

Note: only use the DVD of the Ubuntu version that you wish to repair. So for 14.04, use the DVD of 14.04.


b. Now you need to find out what's the name (and the partition number) of the root partition (the partition on which your Ubuntu has been installed).

Check this with the application Gparted Partition Editor. Gparted is present both on the Ubuntu DVD and on the Linux Mint DVD.

Tip: the root partition of your Ubuntu will usually be formatted in EXT4. The EFI partition wil probably be formatted in FAT32, and it'll have the boot flag.

On my computer, the Ubuntu root partition is called sda5. For the sake of clarity I'll use that situation in the rest of the how-to.

c. Launch a terminal window.
(You can launch a terminal window like this: *Click*)

d. Copy/paste the following command line into the terminal (you can copy/paste with a right-click of the mouse):
sudo mount /dev/sda5 /mnt

Note: only if Ubuntu is on sda5! Change the number according to your situation.

....and press Enter. This mounts the Ubuntu root partition on the hard drive.


e. Copy/paste this command line into the terminal:
sudo grub-install /dev/sda --root-directory=/mnt

....and press Enter. This installs Grub.

Note: definitely use copy/paste and do not type this command by hand! Many people forget to type essential spaces in this command.

Note: you might get the following harmless error report:
grub probe: error: failed to get canonical path of /cow
Installation finished. No error reported.


As said, this grub probe error is harmless, and all should be well.

Now type in the terminal:
sudo reboot

....and press Enter.


f. Reboot the computer normally, so don't forget to take out the DVD first.

Now you can only see Linux in Grub, but no Windows (when Windows has been installed after Ubuntu).

Put Windows back in the Grub menu:

- Start Ubuntu normally.

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

type (better yet: use copy/paste):
sudo update-grub

- Reboot your computer. Windows will (again) be visible in the Grub menu. If necessary, you can make the Grub menu visible when you turn on your computer, by pressing the Shift key after the BIOS screen disappears, and keeping it pressed.

This is different from the old Grub, which used the Esc key! An unfortunate decision by the Grub developers, but that's the way it is.

Repair Grub for Windows 8 computers (EFI or UEFI)

3. The how-to for repairing Grub for Windows 8 computers (EFI or UEFI) can be found here.

Adapt Grub: make Windows the first option in the Grub boot menu

4. At the beginning of their Linux adventure, many people want to make Windows the default operating system to boot in the Grub menu (you'll get over it!).

That's not hard; this is how you do it.

Adapt Grub: set a nice picture as background for the menu

5. The Grub menu, from which you can choose what operating system to boot, is functional but not very nice....

That can be improved greatly, for example by using a holiday picture as background for the menu.

Want more tips?

6. Do you want more tips and tweaks for Ubuntu or Linux Mint? There's a lot more of them on this website!

For example:

Speed up your Ubuntu

Firefox: improve it

Chrome: tweak it

Libre Office: tune it

Solid State Drive: optimize it


To the content of this website applies a Creative Commons license.

Back to the home page

Disclaimer

This website is being sponsored by Google Ads.

Are you using an ad blocker? Then you're also blocking my earnings from advertisements....

If you wish to support my website, you can configure your ad blocker to make an exception for this website.

Thanks in advance....


Remove Grub (back to Windows only)

7. Removing Grub is actually a pity.... it's such a beautiful tool! However, it'll increase your confidence in Grub if you know how to remove it as well.

In short, removing Grub means the replacement of Linux bootloader Grub, by the Microsoft bootloader NTLoader, in the Master Boot Record (MBR) of the hard disk. There are a lot of ways to do that.

With the Windows XP installation CD

7.1. Boot your computer from a Windows XP installation CD and choose R for restore or repair. Then you get a terminal with a menu. Choose the number of the Windows partition, typically 1 for c:\windows , and type the administrator password.

Install NTLoader with the following consecutive commands:
fixboot C:
fixmbr

Done! You should be able to reboot into Windows.

With the Windows 7 installation DVD

7.2. First of all, you need an installation DVD of Windows 7. Don't have an install DVD of Windows 7? Then get a free copy of an evaluation disc of Windows 7, from Microsoft.

You need a free Windows Live account for that, but you can (if needed) created one on the spot. A fake name will do just as fine as your real name.

Burning the iso needs to be done in a special way: click for the how-to

This is what you do then:

a. Put the Windows 7 installation disc in the DVD drive and reboot the computer.

b. Press a key when asked to (spacebar is always safe)

c. Choose your language and keyboard, and press Next.

d. Click Repair your computer.

e. Click on the operating system that you would like to "repair" and then click Next.

f. In the System Restore Options, click Command Prompt.

g. Type:
Bootrec.exe /FixBoot
Press Enter.

(Note: there is a space between exe and / )

h. Then type:
Bootrec.exe /FixMbr

Press Enter.

(Note: there is a space between exe and / )

Done! You should be able to reboot into Windows.

With the installation DVD of Windows 8.x or 10

7.3. First of all, you need an installation DVD of Windows 8.x or 10. Don't have such an install DVD? Then get a free copy of an evaluation disc of Windows 8.x or 10, from Microsoft.

You need a free Windows Live account for that, but you can (if needed) created one on the spot. A fake name will do just as fine as your real name.

Burning the iso needs to be done in a special way: click for the how-to

What you have to do with the DVD of Windows 8.x or 10, is described on this page.

With the free Ultimate Boot CD

7.4. No installation CD or DVD of Windows? Then you can restore NTLoader also by using the free Ultimate Boot CD (UBCD). You can download it here.

Pick the .iso of the stable version, and burn it on a CD as a raw image.

Boot your computer from the UBCD (make sure that the CD drive is first in the boot order in the BIOS).

UBCD contains several tools to restore NT Loader in the MBR. I'll describe the use of one of them.

Select HDD in the menu, then Boot Management, then Super Grub Disk. Then press Enter again, in order to start the Super Grub Disk. Then you choose:
Win => MBR &  !WIN!   :(((((((((((((((((((((((((((((((((
Press Enter.

By the way: the multitude of arches (sigh) isn't my idea, but the idea of the maker of the Super Grub Disk...

Now you're done! Reboot your computer normally. Your computer should boot up Windows now.

With an USB memory stick

7.5. Finally, you can also use a USB memory stick for this job. It takes three applications: Unetbootin, FreeDOS and Testdisk for DOS.

a. First download Unetbootin and use it to make a bootable USB memory stick. Choose Freedos when prompted for a distribution to install on it.

b. Download Testdisk for DOS (don't pick the bèta, but pick the stable version).

c. Unzip the files testdisk.exe and CWSDPMI.exe, and put them on the bootable memory stick (not in a folder, just straight on it).

d. Boot your computer from the memory stick. At the Default window, simply press Enter.

e. Now FreeDOS is being launched. Choose:
FreeDOS Safe Mode (don't load any drivers)
Press Enter.

f. Then type: C:
Press Enter.

g. Now type: testdisk
Press Enter.

h. Select [No Log]
Press Enter.

i. Select the hard drive concerned: usually the second option (the first option is the memory stick itself!).
Press Enter.

j. Select [Intel]
Press Enter

k. Select [MBR Code] and press Enter. When prompted, type y (yes) and press Enter again.

Now you're done! Reboot your computer normally. Your computer should boot up Windows now.

To the content of this website applies a Creative Commons license.

Back to the home page

Disclaimer

Comments