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

Back to the home page


Contents of this page:


Introduction

1. The Grand Unified Bootloader, better known as Grub, 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 old-fashioned BIOS

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 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.


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

a. Boot your computer from the Mint DVD (of from a Live USB with Mint on it).

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

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

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

Tip: the root partition of your Mint 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 Mint root partition is called sda5. For the sake of clarity I'll use that example 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:

sudo mount /dev/sda5 /mnt

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

....and press Enter. This mounts the Mint root partition on the hard disk.

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 Linux Mint).

g. Put Windows back in the Grub menu:

- Start Mint normally.

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

Copy/paste the following command line into the terminal:

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 hitting the Esc key just once, immediately after the BIOS screen disappears.

Repair Grub for modern computers (EFI or UEFI BIOS)

3. The how-to for repairing Grub for modern computers with a pre-installed Windows 8 or 10 (with EFI or UEFI instead of old-fashioned BIOS) can be found here.


Now the section about adapting Grub.

Adapt Grub: don't use Grub Customizer

4. First a warning: don't use tools like grub-customizer for customizing Grub! Your bootloader is far too vital and fundamental to be tampered with by risky stuff that's not even in the official repositories. For safe tweaks, see the items below.

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

5. 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 (item 1).

Adapt Grub: switching the dominant Grub on a multiboot system with more than one Linux

6. When you install more than one Linux operating system on your machine, the dominant Grub is always.... the one of the Linux that you've installed last. At least when you didn't change its default installation options.

This means that what you get to see when you turn on your computer, is the Grub menu of that latest Linux, with that latest Linux as default first boot line.

That can be a problem if you prefer the Grub menu of the oldest Linux. For example because you want to have that oldest Linux as first boot line.... This is how to change dominance back again to the old Grub:

a. Boot into the oldest Linux operating system, namely the one whose Grub should become dominant again.

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

c. First you're going to inform the non-dominant old Grub about the presence of a newly installed other Linux. For that, copy/paste the following command line into the terminal:

sudo update-grub

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

d. Now switch Grub dominance back with this terminal command:

sudo grub-install

Press Enter.

e. Done! When you reboot, you should again see the old Linux as first boot line in your Grub menu. Meaning that the Grub dominance switch has succeeded.

Locking Grub to its current version

6.1. Especially on a multiboot computer with more than one Linux, it can help to prevent problems when you lock all Grub-related packages to their current version (freeze them). In each installed Linux distro. Thus effectively preventing updates for Grub from messing up your boot order.

For that, do the following in each installed Linux distribution:

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

b. Copy/paste the following command line into the terminal:

sudo apt-mark hold "grub*"

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

Want to undo? Undoing is easy; for that, you can use this command:
sudo apt-mark unhold "grub*"

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

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

Fortunately the looks of the Grub menu can be improved greatly, for example by using a holiday picture as background for the menu.

Adapt Grub: changing the timeout

8. In the configuration file /etc/default/grub you can change the timeout of the Grub menu as you please.

Note that setting it to 0 might have no effect: the system might reset it to 10 seconds.... A workaround is setting GRUB_TIMEOUT to 0.1 because the system does always accept one tenth of a second.

Below I'll explain step-by-step how changing the timeout can be done, by using the example of setting the timeout to 3 seconds:

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

b. Copy/paste the following command line into the terminal:

xed admin:///etc/default/grub

Press Enter.

(the three consecutive slashes are intended and no typo!)

c. Set the timeout to 3 by modifying the existing timeout line:

GRUB_TIMEOUT=3

Save the modified file and close it.

d. Copy/paste the following command line into the terminal, in order to execute the modification:

sudo update-grub

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

(if you type the command: note the dash between update and grub)

e. Reboot and test: your Grub menu should be visible for three seconds now.

Adapt Grub: modifying the entries in the menu of a multiboot PC

9. Do you have a multiple bootable computer, on which you've installed more than one version of Linux Mint? Then it can be useful to customize the Grub menu entries, so that it's clearer for you which Linux you'll boot.

Grub menu: how to make it visible

10. On a single-boot computer, you might never get to see the Grub bootloader menu. In such a case you can make the Grub menu visible when you turn on your computer, by hitting the Esc key just once, immediately after the BIOS screen disappears.

However, hitting the Esc key just once at the exact right moment can be difficult. In that case, hit the Esc key repeatedly, immediately after the BIOS screen disappears. That increases your chances of success, but at first it'll give you a Grub command prompt without the menu.

No worries, however: at the Grub prompt, type normal and hit Enter. Then immediately start tapping the Esc key again repeatedly, until the menu is displayed after all. This time, don't worry about hitting Esc too many times: tapping the Esc key more than once at this point, won't drop you to the Grub command prompt anymore but will (finally!) give you the long-awaited boot menu.

Want to see the Grub menu always from now on? You can make the Grub menu permanently visible like this:

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

b. Copy/paste the following command line into the terminal:

xed admin:///etc/default/grub

Press Enter.

c. Find the following line:

GRUB_TIMEOUT_STYLE=hidden

Change "hidden" into "menu", so that it becomes:

GRUB_TIMEOUT_STYLE=menu

d. Then find this line:

GRUB_TIMEOUT=0

Change "0" into "5", so that it becomes:

GRUB_TIMEOUT=5

With that, you set the time during which the menu will be shown to five seconds, which should be more than enough.

e. Save the modified file and close it.

f. Copy/paste the following command line into the terminal, in order to actually apply the configuration changes you've made:

sudo update-grub

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

g. You're done! Test it by a reboot.

Grub menu: how to enlarge its text

11. Usually, the Grub menu is already shown in the right resolution for your display. That produces the nicest letters, but sometimes they are far too small. Which may cause a problem for people with decreased eyesight, or might simply be annoying for everybody.

You can enlarge the size of the letters in the Grub menu as follows.

a. In a cleanly installed Linux Mint 20 you can increase the text size in the menu of bootloader Grub, simply by installing a dedicated magnifying package for it. The mere installation itself is enough; no further action required. Proceed like this:

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

II. Copy/paste the following terminal command (this is one line):

sudo apt-get install grub2-theme-mint-2k

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

III. Reboot and enjoy.

b. In Ubuntu and in older versions of Linux Mint you can proceed like this:

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

II. Then copy/paste this command into the terminal:

xed admin:///etc/default/grub

Press Enter.

III. In the text file that has opened, find the following text:

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480


Remove the hash # from the bottom line of that text, so that this bottom line becomes:
GRUB_GFXMODE=640x480

IV. Save the modified text file and close it.

V. Then copy/paste this command line into the terminal:

sudo update-grub

Press Enter.

VI. Reboot your computer. The letters in the Grub menu should be a lot bigger now.

Letters too big? Then set the resolution at 800x600 instead of 640x480.

Adapt Grub: some advanced options explained in more detail

12. Read more about some useful Grub options here (explanation in more detail).

Removing Grub (back to Windows only)

13. 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

13.1. Do you still have Windows XP? You need a real Windows XP installation CD for this, so no mere Recovery disk. If you don't have one, skip this item and go straight down to item 13.4 on this page.

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

13.2. Do you have Windows 7? For this, you need a real installation DVD of Windows 7, so no mere Recovery disk. If you don't have one, skip this item and go straight down to item 13.4 on this page.

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 (space bar 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 10

13.3. If you have Windows 10, you need a real installation DVD of Windows 10, so no mere recovery disk. Don't you have such an install DVD? Then get a free legal copy of an evaluation disc of Windows 10 Enterprise, from Microsoft itself.

You need a free Microsoft 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 file needs to be done in a special way: click for the how-to.

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

With the free Ultimate Boot CD

13.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 parentheses (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 a USB memory stick

13.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/Win9x (so don't select the Windows 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.


Want more?

Do you want more tips and tweaks? There's a lot more of them on this website!

For example:

Speed up your Linux Mint!

Clean your Linux Mint safely

Avoid 10 fatal mistakes


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

Back to the home page

Disclaimer