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.
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
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:
Information confirmed we must add the prefix corresponding to the folder we do this with this command:
Once this is done we will proceed to force load the correct module for this we will support ourselves from insmod
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:
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:
As a last task, we only have to reinstall the grub for this we execute the following command:
Where sdx is where you have your system installed.