How to repair GRUB without LiveCD?

Grub Rescue.

No doubt to it has all happened to us at some point that when you turn on your computer and wait for everything to start normally have you come across an awful screen that more than one is afraid to see, if I mean that you find the following message:

"Error not such device
Grub rescue "

The worst thing is that when you don't know what to do, you think that everything is lost and you will have to reformat your computer, but if you do have some experience, you will know that you must resort to a livecd from your distribution, but what happens when you don't have it on hand.

But that nothing we must understand what causes this problem.

First the main cause of this error it is because our bootloader is corruptedFor whatever reason, be it by updating a new kernel, system or some application or by carelessness you simply damaged a file in this section of your system.

The grub is housed inside the / boot folder, this in some custom installations they are usually installed in a separate partition.

Now understood the damage, we must get to work, for this we will not occupy anything other than our beloved terminal.

Although many are afraid of working without a graphic environment, let me tell you that it is common you just have to put a little of your patience here and above all I assure you that, if you consider that you do not have any knowledge of this, you will learn something new and understand the most basic commands used in Linux.

Solution

We will start with the first command this is "ls" with it we will be shown all the directories as well as the files that are inside it.

Typing ls on the "grub rescue>" screen
It will display the active partitions, something similar to this:

(hd0) (hd0,1) (hd0,2) (hd0,3) (hd0,4)(hd1) (hd1,1) (hd1,2)

Where hdx is the hard driveIf we have more than one connected, the number will be different, in my case I have two discs. In the case of (hdx, #) where # is the partition number, this is how it is configured and how we will identify them.

Now we must find where the grub is hosted inside the partitions that they deployed to us. For it We just have to type ls + the / partition
Staying as follows

ls (hd0,1)/

In this manner We will begin the search for the / boot folder within the list of partitions that we display previously, it is important not to forget the / since what we are dictating is that it shows us the list of the directories it contains.

Ya identified partition where is the grub partition hosted, we must now make sure that it contains the necessary files to repair the boot of our system for this we only add the following to the previous command.

Assuming the boot folder is inside the first disk on your first partition:

ls (hd0,1)/boot/grub

Information confirmed we must add the prefix corresponding to the folder we do this with this command:

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

Once this is done we will proceed to force load the correct module for this we will support ourselves from insmod

insmod (hd0,1)/boot/grub/linux.mod

If you have doubts about the nomenclatures of the files inside your boot folder, remember the ls command, this will be your best ally during this process.

Now we will proceed to tell the system the root of the grub for this we do it with this command:

set root=(hd0,1)

Finally we will proceed to load the Kernel to the grub For this we use the following command, it is merely explanatory here since everyone has a different version of the Kernel, remember the ls command to verify which one you have, always use the most current version.

linux /boot/vmlinuz-4.13.3-generic-generic root=/dev/sda1

Solo we must here define the partition where it is located as I mentioned the nomenclatures of the partitions here we must already use the ones we commonly use where
hd0,1 would become / dev / sda1 hd1,1 / dev / sdb1 etc.

Finally, we just run the following command and with that we can see our options to start our system:

boot

As a last task, we only have to reinstall the grub for this we execute the following command:

grub-install /dev/sdX

Where sdx is where you have your system installed.


8 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Luis said

    Too much fuss, with how easy it is with SuperGrub2:

    -download SuperGrub2

    -copies it with DD on a USB

    -Boots with USB and charges the system.

    -In case of ubuntu: sudo grub-install / dev / sdx and then sudo update-grub2.

    I solved.

    1.    yop said

      Ugh what a super genius, I want to be like this guy when I grow up, sure he still uses Windows and buys directly from the desktop xdxdxd

  2.   Ineedabrain said

    Buff, what a mess, when I have problems I fix it with the BootRepair cd and throw miles, my head does not give much xD

  3.   FaustoMX said

    It's about learning… and the explanation is excellent.
    If we are going to reinstall it! It is about seeing alternative methods of solution and the method that David explains works and well.

    Regards,

    Fausto Zavala

  4.   Milena said

    they brought me my laptop with:
    error: unknown file system.
    Grub Rescue.
    when I do it happens to me that it appears to me
    (hd0) (hd0,2) (hd0,1)
    I follow the ls + partition
    but in both it says UNKNOWN FILESTSYEM so I don't know where the grub is.
    any idea why that happens?
    sometimes it also says "no such partition"
    as if there was nothing at all

    1.    Alberto said

      Did you manage to fix it? I have the same problem

  5.   Manuel said

    It gives me an error in the line in which insmod is written ... linux.mod. There the story ends

    1.    Duck said

      in my case linux.mod was inside the / boot / grub / i386 directory