GRUB2 Migration

The goal of this guide is to provide readers with a smooth migration from GRUB Legacy to GRUB2.

What's GRUB?
GRUB is one of the most commonly found boot loaders in use on non-embedded Linux machines. The role of GRUB is to facilitate the Linux kernel being loaded from the disk into memory and start executing the Linux kernel.

Why migrate?
Firstly, GRUB Legacy is no longer maintained and as such no longer receives updates. GRUB Legacy was created at a time when the developers felt safe in making several assumptions which no longer hold true today. For example, GRUB Legacy is unable to boot from disks larger than 2 TB and assumes that newer filesystems wouldn't come to replace.

GRUB2 aims to be more robust, more portable, more powerful and is maintained with a cleaner code base. GRUB2 supports more hardware configurations, more filesystems and more drive layouts than its predecessor.

Migration to GRUB2
Migration to GRUB2 is fairly straightforward: it will be pulled in as part of the regular upgrade process by the package manager. If it is not pulled in automatically, it can always be merged via the  package atom:

Boot drive
The first important part is to understand which drive is bootable. For those who followed the Gentoo Handbook it should be. For those who are uncertain, the easiest way to find out is to look at the existing GRUB Legacy configuration. Viewing the file is the main place to check.

The will look something like this:

Based on the above file it is possible to know that  is the boot drive but we must map this to a real device. To know this you must view. An example one is provided below.

Based on the above file we know that is the boot drive.

Installing and configuring GRUB2
The next step is to install and configure GRUB2 for the partition without removing GRUB Legacy from the drive's MBR. The example below uses but you must replace it with your boot drive path. The first step installs the necessary GRUB2 files to, while the second step scans your available kernels and generates a suitable config file to. Skip the second step when using a Manual Configuration.

Chainloading GRUB2 from GRUB Legacy to test the setup
Because a broken GRUB configuration could mean an unbootable system, we want to test our GRUB2 configuration before making it permanent. To do this we will chainload GRUB2 from GRUB Legacy. This is done by adding a new section into. An example is shown below.

At this point you should reboot your machine and select  from the GRUB menu when your machine begins to boot. You will be presented with another GRUB menu which should advertise itself as GRUB 2.0.0 or higher at the top and show your available kernel(s) to boot. Should this not work, simply reboot your system and pick your normal boot option instead of.

Replacing and removing GRUB Legacy
At this point, if everything worked successfully, you can replace GRUB Legacy and remove it from your system.

At this point you can use your package manager to remove.

The migration is complete.

Maintaining GRUB2
Whenever you install a new kernel, you must perform the next step so that your GRUB2 configuration recognizes the new kernel (unless you are using a manual configuration).