Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two partitions with ubuntu installed on each of them.

I removed one of the partitions with g-parted live, and when I reboot, I expected grub still to display with the other partition with Ubuntu on it to boot from. However, instead I get an error, I can't remember what it said but it wouldn't let me boot.

I had to create another partition and install Ubuntu again, just to get grub back, which was a pain.

A few days later I create another partition and install windows 7 on it, and during boot, grub was gone again, it would only boot from windows, even though I had Ubuntu installed on another partition. So, once again, I had to create a new partition and install Ubuntu just to get grub back.

Is there any way to keep grub when creating and removing partitions?

share|improve this question
up vote 2 down vote accepted

You could always mend your grub with Boot Repair. This is a really useful guide for those who need it or for if your grub vanishes due to loading another OS.

share|improve this answer

As SimplySimon says, Boot Repair can sometimes fix things after the fact. To understand what's going on, though, there are two cases:


On a traditional BIOS-based computer, the firmware (the BIOS) reads the first sector of the hard disk (aka the Master Boot Record, or MBR) and executes the code it contains. Thus, whatever code is in the MBR controls the boot process of the computer. (Modern computers give limited control by enabling you to specify which hard disk to boot, but this is only useful on multi-disk computers.)

In order to make a computer bootable, an OS installer must be able to install a boot loader to the MBR. That said, some installers make this step optional, relying on the user to know when another boot loader is already installed. Microsoft has always made installation of a boot loader to the MBR non-optional, and Linux distributions aimed at less experienced users have been going this same route in recent years.

The end result of this is that the last OS you install is the one that will control the boot process, unless that last-installed OS gave expert-level control of boot loader installation. If this isn't what you wanted, boot loader re-installation is the only option. Ubuntu's Boot Repair tool helps to automate this task, but there are other ways to do it, too.


Newer computers use EFI firmware rather than a BIOS. (Confusingly, though, manufacturers and most users continue to use the term "BIOS" in reference to the EFI. This usage is technically incorrect, and IMHO it fosters confusing misunderstandings.) These computers store boot loaders as ordinary files on the EFI System Partition (ESP). You can store as many boot loaders as you like on the ESP. They're referred to in NVRAM entries created via Linux's efibootmgr or equivalents in other OSes.

When an OS installs itself, it will typically register its boot loader and make it the default; but you can typically switch to another boot loader by hitting a function key during the boot process. Unfortunately, the key to press to manage the boot process is entirely non-standardized, and some computers are rude enough to not even activate the keyboard during the boot process, so it may be impossible to make such a change -- at least, not without altering some firmware settings.

In practice, therefore, the EFI behavior looks very much like the BIOS behavior: The last-installed OS's boot loader takes precedence. The difference is that the recovery method under EFI does not require re-installing the boot loader; it just requires using efibootmgr or some other tool to change the boot order. The Boot Repair utility will do this, but it also does a lot of other things, some of which are usually unnecessary and can be harmful in the long run. Thus, I'm not a big fan of Boot Repair on EFI-based computers. If you're lucky, your firmware will offer a way to permanently adjust the boot order, but this capability is relatively rare.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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