Connect with us

Website Tutorials

Grub Rescue: Everything You Need To Know

Published

on

Grub Rescue: Everything You Need To Know

Grub is one of those programs that works in the background, and if everything goes well, you might not even notice that it exists. You boot your server, log in via SSH, and that’s that. What more do you need? The truth is that a lot is happening before you get to that SSH prompt, and Grub is the program that makes sure you can use your server. You never see it. Grub rescue, on the other hand, only appears when something goes wrong. In this article, I’ll explain what grub and grub rescue are, and why you need to be aware of them.

Grub Overview

GRUB stands for GRand Unified Bootloader, and it’s the software that first loads onto a Linux server when it starts up. It’s not an operating system, though. Instead, its job is to bring the Operating System online by performing bootup operations like loading the kernel and starting the boot process. If everything goes smoothly, you need never even know that it exists.

Allows you to Choose the Operating System

For slightly more complex setups, you might have more than one operating system installed on your computer and need to choose which one to start. GRUB allows you to make this choice at the beginning. Depending on what you choose, it’ll load the kernel with the appropriate parameters.

Grub also lets you perform advanced boot operations like booting from an ISO file stored on your hard disk without the need to burn it onto a disc.

Grub Rescue – When Things Go Wrong

Grub rescue is the component of grub you typically don’t want to see. It means that something has gone wrong with the bootloading process, and you need to fix it. For someone who hasn’t faced this before, it can be a scary thing, especially since there’s no GUI involved, and you don’t know what you can do, and what the commands are. It’s intimidating, and if you’re in charge of your server, you’ll have a tough time figuring out what’s wrong, and how to fix it!

Advertisement

You’ll Never See Grub Rescue with a Hosted VPS Server

Fortunately, when you purchase one of SirsteveHQ’s hosted VPS servers, you never need to worry about seeing the grub rescue screen. There are two reasons for this.

First, the standard way for you to manage your server is via SSH for a hosted setup, and you can’t access grub rescue from SSH. This is because grub and grub rescue operate on a level that’s far below what SSH operates on. SSH assumes that the Linux operating system is properly running, and that the sshd daemon is active, and that your system is open to SSH connections. But Grub is the first software that loads on your machine, even before the operating system.

If grub rescue is needed, then SSH is very far from being able to work on a hosted VPS system. So as a hosted user, you will never either grub or grub rescue from an SSH terminal.

The second reason why you don’t have to worry about grub problems with a VPS like NameHero’s is that the administrators of the server – NameHero’s customer service will solve any problems you have with your bootloader. Ideally, you shouldn’t be messing around with bootloader files anyway, but if you have been doing so for whatever reason, then a simple customer service request ticket to NameHero’s technical support will fix whatever problem you have—no need to learn arcane grub rescue commands, or worry about partitions.

So the remainder of this article is only for users with direct control over the machine on which they run Linux. Either from a console on a regular server or because they’ve installed Linux on their local PC and are running into problems. It’s not meant for hosted VPS servers.

Advertisement

How to Trigger Grub Rescue Manually

As mentioned above, Grub rescue only shows up when something goes wrong with the boot process. This isn’t a mere process error, but a severe problem that prevents Linux from loading at all. So there’s no way to test Grub rescue on a perfectly functioning system. You have to deliberately break something for that to happen. Needless to say, this can be dangerous.

Don’t Attempt this over SSH!

Before I show you how to manually trigger Grub rescue, I must warn you not to do this if you’re connecting remotely to your VPS server via SSH. If you do this and restart the server, Linux won’t load and you won’t be able to connect to it via SSH again, you’ll need to open a ticket with your hosting provider to fix the problem from there – something which will be hard to explain as to why you did this on purpose!

WARNING!
Unless you have physical access to the server console, don’t try and trigger Grub rescue manually.

Rename the grub.cfg file to a Backup

If you’re sure you want to trigger grub rescue manually, the easiest way is to rename the “grub.cfg” file and make a copy of it. To do this, go to the following directory:

/boot/grub

If you don’t find the above directory, try this one, depending on what flavor of Linux you’re running:

Advertisement
/etc/default/grub

In this directory, you should see the “grub.cfg” file as shown in this screenshot:

grub.cfg Location
grub.cfg Location

Grub needs the above file to proceed with the installation since it contains the menu entries and other configuration files. If it doesn’t find it, it will throw you into grub rescue. We can rename this file like this:

sudo mv /boot/grub/grub.cfg /boot/grub/grub.cfg.backup

Now “grub.cfg” doesn’t exist anymore and if you reboot your system, you will see the Grub rescue mode. From here, you’ll have to restore the grub.cfg file. The commands you use on grub menu aren’t the same as the ones in bash, so that will be a different tutorial.

Things that Trigger Grub Rescue

Apart from a missing grub.cfg and other grub configuration files, here are some of the things that can cause Linux to fail to load and trigger the Grub rescue screen.

Filesystem Corruption

Grub pulls essential boot files off the hard drive, from which it loads the kernel and other files. By default, Grub can read the following file formats, including:

  1. Ext2, ext3, ext4
  2. Btrfs, XFS
  3. FAT32
  4. F2FS

If the boot or root partition is corrupted, and Grub doesn’t recognize the filesystem anymore, it will throw you into the Grub rescue mode.

Boot Record or Partition Table Corruption

Like the file system, Grub needs to retrieve information from the boot record so that it knows which partitions exist and where to locate them. If either the partition table or the boot record is corrupted, Grub can no longer proceed and will trigger the Grub rescue interface.

Advertisement

Hardware Problems

Not surprisingly, if you remove the boot drive to another machine, or if the drive itself fails, Grub can’t load anything from it and you’ll see the Grub rescue screen.

Conclusion

Grub rescue is one of those interfaces you hope you’ll never see. If you’re on SSH, you will never see it because SSH needs Linux and SSH to be working in the first place. You can trigger the Grub rescue screen by manually renaming the grub.cfg file, but proceed with caution!

Stephen Oduntan is the founder and CEO of SirsteveHQ, one of the fastest growing independent web hosts in Nigeria. Stephen has been working online since 2010 and has over a decade experience in Internet Entrepreneurship.

Continue Reading
Advertisement
Comments

Trending

Copyright © 2024 SirsteveHQ. All Rights Reserved.