Terry : Using CLI to Boot

Using CLI to Boot

If the user has problems booting but the menu is available, the easiest method to boot the system is to edit the existing menu. Refer to Editing Menus During Boot. 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.

Note: If the command line prompt is not already active press "c" to enter the Command Line mode. You will see the GRUB 2 prompt: grub> or grub rescue>

If you wish to cancel and start over at any time, ESC will remove changes and return the user to the previous menu.

Use the following two commands to determine the device (drive) and partition of the system you wish to boot.

set
When set is typed without additional entries the command displays the current GRUB 2 settings.
ls
Run ls to see the devices recognized by GRUB 2. Example: (hd0) (hd0,1) (hd1,5) In this example sda, sda1, sdb5 are recognized.

Express Boot to the Most Recent Kernel
Command Summary:

set root=(hdX,Y)
linux /vmlinuz root=/dev/sdXY ro
initrd /initrd.img
boot

Expanded Instructions:

Press ENTER after completing each line. Some entries will not provide feedback. This is normal.
If a "file not found" or similar error message is displayed while running these commands, ensure you are using the correct X,Y values. The ls command can help determine the correct values. Once the X,Y values are confirmed run the following command:

set prefix=(hdX,Y)/boot/grub

1. set root=(hdX,Y)
Type with correct X,Y results from the ls command and press ENTER. Remember GRUB 2 counts the first drive as 0, the first partition as 1. Example: If the Ubuntu system is on sda5, enter: set root=(hd0,5)

2. linux /vmlinuz root=/dev/sdXY ro
Example: linux /vmlinuz root=/dev/sda3 ro

3. initrd /initrd.img
Selects the latest initrd image.

4. boot
Boot to the latest kernel on the selected partition.

These changes are not permanent. After successfully booting into the system the user should run sudo update-grub and inspect the GRUB 2 configuration file (/boot//grub/grub.cfg). For problems with booting the main linux kernel, ensure the search, linux, and initrd lines in the ### BEGIN /etc/grub.d/10_linux ### section of the file now correctly point to the correct locations. The user may need to reinstall GRUB 2 (sudo grub-install /dev/sdX).

Ubuntu 10.10 example:
OS: Ubuntu 10.10 maverick x86_64
Kernel: 2.6.35-22-generic
/boot on (hd0,1) (/dev/sda1)
LVM
/ file system on /dev/mapper/ubuntu-root (/dev/ubuntu/root)

ls (hd0,1)
set root=(hd0,1)
linux /vmlinuz-2.6.35-22-generic root=/dev/mapper/ubuntu-root ro
initrd /initrd.img-2.6.35-22-generic
boot

Some of the more useful commands include:

Command

Result

background_image

Load an existing background image. Use tab completion to help complete filename entries!background_image=/usr/share/images/grub/ then tab to display a list of all images. Useful command when initially testing splash images.

cat

Use to display the current file contents. cat /boot/grub/grub.cfg , cat /etc/fstab

help

View all available commands. Type help x to get a list of commands beginning with the letter x.help xxx for information about the xxx command. This command should be preceded by running "set pager=1", which acts like the terminal's "| more" command, to prevent scrolling past the top of the screen.

ls

Used alone, lists all devices known to GRUB 2, such as (hd0) (hd0,1), etc. View available partitions with ls. View /boot and /grub directory contents with `ls /boot, ls /boot/grub

initrd

Load an initrd.

linux

Load a linux kernel.

loopback

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

lsmod

Display loaded modules

reboot

Reboot the machine

rescue

Enter the rescue mode

set

Show environmental variables in place. Combined with others, set variables such asset gfxmode=640x480set color_normal=cyan/black Use the latter command in command line mode to test various menu font colors.

vbeinfo

Display available monitor resolutions.