Repair Linux Boot failures in Grub 2 rescue mode

As GRUB 2’s ability to fix boot problems is greatly improved over the original GRUB bootloader. This article provides the you with information on options available for repairing GRUB 2 boot issues and specific instructions on how to use the GRUB 2 terminal. The instructions are written for GRUB 2.

How it looks?

There are basically three messages or error or screen mode whatever you say, when grub fails to boot.

grub: This is the screen mode you see when grub has found everything ecept the configurationn file. This file probably will be grub.conf.

grub rescue: This is the mode when GRUB 2 is unable to find the grub folder or its contents are missing/corrupted. The GRUB 2 folder contains the menu, modules and stored environmental data.

GRUB: Just “GRUB” nothing else indicates GRUB 2 failed to find even the most basic information needed to boot the system.

This is are the basic errors that we se on the boot. Althought there are few more errors that can be seen on the screen like frozen splash screen, Busybox or Initramfs: GRUB 2 began….
But each of the GRUB 2 failure modes can be corrected either from GRUB 2 terminal or the Live boot CD or DVD of the distro , there are also 3rd party rescue tools available out there.

Basic Commands available.

This are the commands that can be used when when you enter the GRUB 2 terminl mode by pressing “c”.

boot (Initiate the boot, also F10 or CTRL-x)

cat (view the contents of config or txt files; cat (hd0,1)/boot/grub/grub.cfg)

configfile (Load a GRUB 2 configuration file such as grub.cfg; configfile (hd0,5)/boot/grub/grub.cfg.)

initrd (Loads the initrd.img, necessary for booting; initrd (hd0,5)/initrd.img.)

insmod (Loads a module; insmod (hd0,5)/boot/grub/normal.mod, or insmod normal.)

linux (Loads the kernel; insmod /vmlinuz root=(hd0,5) ro.)

loop (Mount a file as a device; loopback loop (hd0,2)/iso/my.iso.)

ls (lists the contents of a partition/folder; ls, ls /boot/grub, ls (hd0,5)/, ls (hd0,5)/boot.)

lsmod (List loaded modules.)

normal (Activate the normal module, if loaded.)

search (Search for a device. Type help search for the available options.)

set (Review current settings, or set XXX to set a variable such as colors, prefix, root.)

vbeinfo (Display GRUB 2 available resolutions.)

The Rescue Shell.

If you get a rescue shell, this usually means that GRUB failed to load the “normal” module for some reason. It may be possible to work around this temporarily: for instance, if the reason for the failure is that “prefix” is wrong (perhaps it refers to the wrong device, or perhaps the path to “/boot/grub” was not correctly made relative to the device), then you can correct this and enter normal mode manually: Inspect the current prefix (and other preset variables):

set

You will probably have an output more or less like this:

Your output may differ but you get the information required. Find out which devices are available:

ls

Set to the correct value, which might be something like this:

set prefix=(hd0,1)/grub

(this has to be done according to your own drive name)

set root=(hd0,1)

(this has to be performed according to your own drive name.)

insmod normal
normal

The above commands will get you out of the rescue mode to the normal terminal mode. In the terminal mode you have more commands and with increased functionality.
After the above commands you can go ahead and start the rest of the settings.

insmod linux
* linux /vmlinuz root=/dev/sdXY ro

(if this doesn’t work try this)

linux /boot/vmlinuz-3.2.0-14-generic root=/dev/sda1 ro

(optional)

initrd /initrd.img

(Selects the initrd image.)

boot

After Booting in to the system.

Update the grub config file.

sudo update-grub

Reinstallation of grub on the device:

sudo grub-install /dev/sdX

This should the thing for the rescue part and your system should be good and running. If not you can save all your trouble by using Boot Repair. This is the tool used to repair your complete boot menu. It can be downloaded directly and used as a Live Boot CD or DVD. Here is the download link.

 

Startup Applications: automatic execution of the most used programs during every user login

During every login or bootup, the OS performs a number of tasks in the background to get the OS up and running and ready to be used. Customizations in Linux OS like Ubuntu can be done very easily, that allows an user to add any number of “custom” tasks or programs to the system to be performed every time the user logs in or boots up the OS.

We can choose a certain number of tasks to be automated, thereby reducing the repetitive work of the user to quite an extent. The tasks that can be automated include running a certain program like a custom system check that the user might want to view, or to run applications like the web browser with certain predefined websites. Or it can be automating system control programs that needs to be run during each bootup or even login. Ubuntu allows us to do these kind of automation in a very simple manner, by providing us a GUI based software called the “Startup Applications”.

Though this may provide a lot of convenience, it is important to remember not to overuse this feature. Users might face problems when a large number of tasks are provided or selected to be automated. The main problem this leads to is slowing down your system at startup. Hence, it is very important for the user to NOT over utilise this functionality and only automate the most required or used tasks.

So let’s begin. First thing to do is to open the Startup Applications. To do so, in the desktop Dash, type

Startup Applications

as shown in the image below.

Ubuntu Desktop - Startup applications

Click on the “Startup Applications” icon, and the Startup Applications window opens. It will look similar to the image below. Note that you might have a different set of entries in your window than the ones that can be seen in the image below.

Startup applications preferences

Once this is open, we can start with the automation of tasks. This posts will demonstrate some of the tasks, but many other tasks that are important to you can be added the same way. So here are a few examples

1 Starting a browser with a predefined web page

Every build of Ubuntu comes with Firefox inbuilt. We can use that to open websites that we check regularly. For example, I like to read Linux news, from the website “lxer.com”. To open this website every time, click on the add button present on the upper right side of the Startup Applications window.

Another window opens. In the new window, type the following in the command field:

Firefox “http://www.lxer.com”

Fill out the name as well and use the comment field to describe your new task. An example is shown in the image below. Once that is done, click on the “Add” button and you will see an entry named “lexr Linux news” (in this case) in the Startup Applications window.

Add startup program

This way, a browser can be opened automatically with any website or search query. For example, if the first thing you do is view the trade stock market, then you can click “Add” and enter the command to go directly to a trade website. Example:

Firefox “NASDAQ”

2 Running system management functions automatically

Certain system management functions or programs require to be started each time a user logs in. Consider the situation of system overheating experienced by many Ubuntu users. In this case, most of the users install a software called “TLP”. And in many cases, TLP doesn’t always start on its own automatically. In such a case, rather than to run it manually each time, the Startup Applications can be used to run it automatically, by following the similar steps. So, click on the “Add” button and use the following command in the command field:

sudo tlp start

For the name and the comment field, refer to the image below:

sudo tlp start

Unlike the first example, this example of TLP , the program is started in the background and not visible to the user. Thus in this way, a user can start a variety of background processes automatically that relate to system management functions.

3 Starting system monitoring programs

System monitoring programs are those that monitor and report the various functionalities of the system. An example can be a program to monitor the broadband bandwidth consumption or a custom program written by you to monitor system features like heat of the cpu or cpu utilisation ,etc. These programs are actually running in the background, but unlike the previous example of TLP type of programs, it can be brought to the foreground by either using icons on the top taskbar or an icon on the side taskbar. This too has a similar procedure as the two procedures above. So, click on the “Add” button of the Startup Applications and enter the commands to run it. An example would be the program to monitor cpu frequency and scaling tool. The image below shows an example. The user is also allowed to enter options along with commands.

Edit startup program

4 Editing and removing an automated task

There will be times when an automated task might no longer be needed or you might want to change the website that is loaded. In such cases, you would want to edit or remove the task. There might be situations when you have installed a program that automatically starts by itself and whose entry then can be found in the startup application window. Even that can be removed or edited.

  • To edit a task, simply select on the task to be edited and click on the “Edit” button on the right side of the Startup Applications window. Do the changes in the window that opens.
  • To remove a task, select the task to be removed and click on the “Remove” button. Please note that some of the edited or removed tasks might require a reboot to apply the changes.

Conclusion

We have seen how we can automate many of the user defined tasks to make our job a little bit simpler. The tasks might belong to one of the types shown above or it can be something completely different, but it can be assured that if it is repetitive, it can be automated. The Startup Applications are indeed useful when it comes to running multiple tasks. Still consider that this feature should not be exploited by using it excessively.