26.8. Upgrading from GRUB Legacy to GRUB 2

When you do an in-place upgrade of Red Hat Enterprise Linux (RHEL) from version 6 to 7, the upgrade from GRUB Legacy to GRUB 2 does not happen automatically, but it should be done manually. Perform the GRUB upgrade for these reasons:
  • In RHEL 7 and later versions, GRUB Legacy is no longer maintained and does not receive updates.
  • GRUB Legacy is unable to boot on systems without the /boot/ directory.
  • GRUB 2 has more features and is more reliable.
  • GRUB 2 supports more hardware configurations, file systems, and drive layouts.

Upgrading from GRUB Legacy to GRUB 2 after the in-place upgrade of the operating system

Procedure 26.2. Upgrading from GRUB Legacy to GRUB 2

  1. Ensure that the GRUB Legacy package has been uninstalled by the Red Hat Upgrade Tool:
    ~]# yum remove grub


    Uninstalling the grub2 package does not affect the installed GRUB Legacy bootloader.
  2. Make sure that the grub2 package has been installed. If grub2 is not on the system after the upgrade to RHEL 7, you can install it manually by running:
    ~]# yum install grub2

Generating the GRUB 2 configuration files

Now we will add GRUB 2 configuration without removing the original GRUB Legacy configuration. We will keep GRUB Legacy configuration in case GRUB 2 does not work correctly.
  1. Install the GRUB 2 files to the /boot/grub/ directory of /dev/sdX disk:
    ~]# grub2-install --grub-setup=/bin/true /dev/sdX
    Substitute /dev/sdX with the bootable device file.
    The --grub-setup=/bin/true option ensures that the old GRUB Legacy configuration is not deleted.


    Note the difference in the configuration file extensions:
    • .conf is for GRUB
    • .cfg is for GRUB 2
    Do not overwrite the old GRUB configuration file by mistake in the next step.
  2. Generate the /boot/grub2/grub.cfg:
    ~]# grub2-mkconfig -o /boot/grub2/grub.cfg


    For customizing the generated GRUB 2 configuration file, see Section 26.5, “Customizing the GRUB 2 Configuration File”. You should make changes in /etc/default/grub, not directly in /boot/grub2/grub.cfg. Otherwise, changes in /boot/grub2/grub.cfg are lost every time the file is re-generated.

Testing GRUB 2 with GRUB Legacy bootloader still installed

This section describes how to test GRUB 2 without removing the GRUB Legacy configuration. The GRUB Legacy configuration needs to stay until GRUB 2 configuration is verified; otherwise the system might become unbootable. To safely test GRUB 2 configuration, we will start GRUB 2 from GRUB Legacy.
  1. Add a new section into /boot/grub/grub.conf.
    For systems with a separate /boot partition, use:
    title GRUB 2 Test
    	root (hd0,0)
    	kernel /grub2/i386-pc/core.img
    Substitute (hd0,0) with the GRUB Legacy bootable device designation.
    For systems without a separate /boot partition, use:
    title GRUB 2 Test
    	root (hd0,0)
    	kernel /boot/grub2/i386-pc/core.img
    Substitute (hd0,0) with the GRUB Legacy bootable device designation.
  2. Reboot the system.
  3. When presented with a GRUB Legacy menu, select the GRUB 2 Test entry.
  4. When presented with a GRUB 2 menu, select a kernel to boot.
  5. If the above did not work, restart, and do not choose the GRUB 2 Test entry on next boot.

Replacing GRUB Legacy bootloader

If GRUB 2 worked successfully, replace GRUB Legacy bootloader with the GRUB 2 bootloader:
~]# grub2-install /dev/sda


After the upgrade, the operating system is unsupported until manual upgrade of the GRUB Legacy bootloader to GRUB 2 has been successfully finished. This is due to the fact that installation of packages across major releases is not supported. In case of RHEL 7, only GRUB 2 is supported, developed, and tested; unlike GRUB Legacy from RHEL 6.