In my previous post of GRUB I explained about the difference between GRUB legacy and GRUB 2.
I have emphasized this post especially on GRUB Shell, because this is something you have to deal with when you are under black sky of miseries, that means when you are unable to log on to your system using bootloader, or boot menu is not what you want.
This page is about the actions and directives you must be using even before booting when you have to edit and rescue system to successfully boot along. (Please note the following setting is going to be for GRUB 2)
Please note if you are not happy with the view of Bootloader menu and want something different instead, then hold down the Shift key and press ‘e’ to edit the menu. Do the changes and press Ctrl-x to boot with changes, escape to avoid them and c to go to the command line to perform diagnostics, load modules, change settings.
Some of the Normal mode commands for using inside GRUB are:
You may switch directly to the command line mode by pressing ‘c’.
‘help’ command will display list of all the commands available.
If GRUB 2 fails to find a usable grub.cfg file it should revert to the grub-rescue mode. The command line prompt will display grub-rescue> and no menu will be displayed. From this command line the user can attempt to manually enter the instructions to boot to a usable system.
‘ls’ displays devices recognized by GRUB. The format of output is like (hd0, hd2,3) which illustrates hda, hdc3.
Please note unset command is always available there to unset any setting you made.
Following is the sequence of commands to set and boot yourself by defining all booting parameters:
2. set prefix=(hdX,Y)/boot/grub
3. set root=(hdX,Y)
5. ls /boot
6. insmod /boot/grub/linux.mod
7. linux /vmlinuz root=/dev/sdXY ro
8. initrd /initrd.img
Expanded Commands from above:
1. ls This will display the known devices and partitions. From this information, the user must determine the device and partition on which the system is installed.
2. set prefix=(hdX,Y)/boot/grub If incorrect, “no such disk” or “not found” errors will occur later.
3. set root=(hdX,Y) In this command, X is the device/drive, starting with 0. Y is the partition, starting with 1. Example: (hd0,1) is sda1. (hd2,5) is sdc5.
4. set Inspect the “prefix=” listing. It should match the root designation in Step 3, in the following format: prefix=(hdX,Y)/boot/grub.
5. ls /boot/ Inspect the contents. The user should see varioius kernels, initrd images and the grub directory. If not, use the ls command to inspect the device and attempt to find these files and directories. If necessary, set another device as root.
6. insmod /boot/grub/linux.mod Load (insert module) the linux module. Without this module loaded, the user will receive an “Unknown command linux” message when trying to load the kernel.
7. linux /vmlinuz root=/dev/sdXY to Load the linux kernel, substituting the correct designations for “X” and “Y” (example: sda1). The user will see a message showing the kernel has been loaded. (See graphic in the previous section above)
8. initrd /initrd.img Load the initrd image. When pressing ENTER the user may or may not see a message in the terminal. (See highlighted graphic above)
9. boot Attempt to boot using the information entered.
These are rescue mode commands: