I'm sure it's happened to you before: you turn on your computer full of excitement and, suddenly, you're faced with a black screen and a cryptic message telling you that the GRUB boot manager has diedYou may have been messing around with disk partitions, installed Windows after Linux and it may have overwritten the boot sector, or a system update may have gone wrong along the way.
The first thing is not to panic, because even though it may seem like your equipment has passed away, your data remains intactGRUB is simply the gateway to the system, and even if the gateway is broken, the house is still there. Depending on what you have available, there are several ways to solve this problem, from using the GRUB console itself if it's still responding, to resorting to a Ubuntu or Debian Live USB to perform open-heart surgery.
Direct recovery from the GRUB console
Si tienes la suerte de que el equipo no arranca pero aún puedes entrar en la línea de comandos de GRUB (pulsando la tecla ‘c’ al inicio), puedes intentar levantar el sistema sin necesidad de un USB externo. Lo primero es identify where your files are located running the command lswhich will show you the available disks and partitions, such as (hd0,msdos1).
Once you have located the disk, you must look for the folder boot exploring the partitions with ls (hd0,1)/When you find the right one, you have to configure the prefix route and the system root using the commands set prefix=(hd0,1)/boot/grub y set root=(hd0,1)Next, locate the available kernel in the boot folder and load it using the command linux, specifying the root partition (for example, root=/dev/sda1), to finally execute initrd and launch the engine.
Once you have successfully logged into your user session, don't forget to permanently repair the starterOpen a terminal as root and run grub-install /dev/sda followed by update-grub2 y update-initramfs -u so that the problem does not repeat itself upon restarting.
Reinstallation using Live USB (Manual and Chroot Methods)
When GRUB is completely missing, the most reliable solution is to use a Live USB of any Debian-based distribution (such as Ubuntu or Linux Mint). The key is that the architecture of the Live USB (AMD64 or i386) matches that of your installed system to avoid errors when running the process. root change or chroot.
The process begins by identifying the partitions with sudo fdisk -lIt's crucial to distinguish which is the root partition (/) and whether you have a separate /boot partition. To proceed, you must mount the root partition at /mnt and, if it exists, the starting one in /mnt/bootFor the system to function correctly within the Live environment, it is necessary to perform a linked assembly of the critical directories of the operating system running sudo mount --bind /dev /mnt/dev, as well as for /dev/pts, /proc y /sys.
With everything assembled, we use the command sudo chroot /mntThis is like doing a magic trick: we tell the computer that The root is now our hard drive and not the USB. From here, we reinstall the manager with grub-install /dev/sda and we updated the settings with grub-mkconfig -o /boot/grub/grub.cfg o update-grubFinally, we left with exit and we restarted.
Automated solutions and quick alternatives
If you don't feel comfortable navigating the terminal or find the process too cumbersome, there's a tool called Boot Repair which is a real lifesaver. To use it, boot from an Ubuntu Live USB, open the terminal, and install the tool from its official repositories. Once running, simply select the option to recommended repair And the program will do all the dirty work for you, detecting the operating systems and automatically reinstalling GRUB.
In simpler cases, where we only need to reinstall GRUB without performing a full chroot, we can mount the partition containing the boot directory in a temporary folder like /tmp/part and run sudo grub-install --root-directory=/tmp/part /dev/sda. This is useful if We're looking for a more direct route and we know exactly where the starter charger is located.
To solve this problem, whether by using manual commands in the GRUB console, the chroot technique with a bootable USB drive, or the use of automatic tools like Boot-Repair, the key lies in correctly identifying the disk partitions and ensuring that the boot sector of the MBR or EFI is correctly linked to the kernel of the installed operating system.



