GRUB2 error recovering

This article is for who had faced, using GRUB2 ( do not confuse with GRUB version 1 ) with the following message:

Minimal Bash-like line editing is supported.

Firstly its worth to say that the following procedure will only work if the partition that has GRUB2 configuration still exists in the hard drive.

The idea is trying to boot into the system from this “shell” provided by GRUB2. In order to do that, just type the following:

set

this will show GRUB2 current configuration.

ls

This will list the recognized partitions by GRUB2. In the example (hd0) = sda; (hd0,1) = sda1. Just imagine the hard drive identification always is one number less that one used by Linux and the partition identification is exactly the same.

Now, to boot up the kernel, just follow the next steps:

  • Inform to GRUB2 where it ( GRUB2 ) is installed ( in the example /dev/sda2):
set root = (hd0,2)
  • Inform the kernel to be loaded ( in the example the type of the kernel is ‘linux’  and its location is in the /boot  directory and its image is called vmlinuz ):

linux /boot/vmlinuz root=/dev/sda2 ro

  • Inform, if exists, the ramdisk image:

initrd /boot/initrd

  • Try to boot the system based on the entered configurations:

boot

It is worth to point out that this will boot the system this time only.  In order to fix this once for all, just re-install GRUB2 ( if that is the case ) and / or edit the configurations of grub.cfg. After that, run ( change sda for the device your computer boots from ).

grub2-install /dev/sda