Quick Fix of grub rescue unknown filesystem error without LiveUSB

If you have this error, then grub (operating system loader) was corrupted. Damage occurred on the disk partition where the Linux system was installed. Grub looks for /boot/grub directory and can’t find it. I had this problem when I move Linux partition to another disk and deleted the old one. But the settings in grub were not changed and after rebooting this problem appeared.

Now when the system starts up, a grub rescue command prompt appears. In simple terms, grub invites us to specify the path to the /boot/grub section manually.

First, enter ls command:

ls
...
(hd0) (hd1)

We will see some content and hard drives of the computer. In my case i have 2 hard drives: hd0 and hd1. They are arranged in order as in Linux. So, (hd0) is equivalent to /dev/sda and (hd1) is equivalent to /dev/sdb.

To pick a partition of the disk we need to add a partition number separated by comma:

ls (hd1,1)/
...
bin  boot  dev  etc  home ...

So I’m in the root directory.

See the /boot directory? It’s definitely our partition! This command may not work if your /boot partition uses another file system than Linux (ext4), like FAT32. Then you need to know where is /boot exactly installed (which hard drive and which partition number).

Make this partition our root:

set root=(hd1,1)

And set path to grub prefix:

set prefix=(hd1,1)/boot/grub

Now we specified grub directory as its native.

Then we need to load and execute the module to boot our system. Use the following commands. First, load the module:

insmod normal

Second, run it by the following command:

normal

If the / boot partition was not damaged, then the bootloader will normally detect all the files, and then launch the menu that is familiar to you.

Grub recovery and reinstalling

If you have several hard drives, you need to install grub on the drive that is set as bootable in BIOS. If you have connected a new hard disk, BIOS can still use the old one as a boot disk. Therefore, grub will need to be installed on the old hard drive.
You can install grub on a new hard disk, then you will need to set it in BIOS as a boot disk.

Use the following command to install grub on bootable disk:

sudo grub-install /dev/sda

Then we need to update grub config by the following command:

sudo update-grub

But on distributions other than Debian-based this command may differ.

Reboot and make sure that everything works fine.

What to do, if /boot has another file system like fat32 and you want to see the contents of other partitions

We need to know exactly on which partition /boot is installed. Or we can find it by setting different numbers.

Set /boot partition as root:

set root=(hd1,1)

Set path to grub directory:

set prefix=(hd1,1)/boot/grub

Show directory contents:

ls (hd1,1)/boot/grub/
...
fonts  grub.cfg  grubenv  i386-pc  locale  unicode.pf2

i386-pc may differ, it depends on processor architecture.

Print all available modules (may need to replace i386-pc with your own directory):

ls (hd1,1)/boot/grub/i386-pc/
...
ext2.mod   zfs.mod    fat.mod   exfat.mod    ntfs.mod   xfs.mod    ufs2.mod (These are modules of file systems that I managed to determine)

Now we need to load the module of desired filesystem (that other partitions are use). Let’s assume that we use ext4 filesystem in our Linux system, then we need to load the corresponding module:

insmod ext2

Now it is possible to read the contents of the disks with another filesystem that /boot is use:

ls (hd1,1)/
...
bin  boot  dev  etc  home  ...

Leave a Reply

Your email address will not be published.