Grub.conf archives - Open Source Software and Linux

Open Source Software and Linux:

grub.conf

Sep 13 2008   12:26AM GMT

Grub and boot errors



Posted by: John Little
Linux, red hat, centos, grub, /root, grub.conf, menu.lst, vmlinuz, initrd

If you’ve administered or customized Linux long enough you’ve no doubt created a situation at some point where, during the boot process, that GRUB throws an error. We’re going to discuss some of these situations below along with ways to work through them.

If a file name or partition in the GRUB configuration file is incorrect GRUB won’t be able to find critical files such as the Linux kernel. For instance if the root directive points to something other than the /boot directory GRUB will throw one of the following errors:

Error 17: Cannot mount selected partition
Error 27: Unrecognized command
Error while parsing number
Cannot mount selected partition

If the GRUB configuration file is completely missing you will see the following:

grub>

If you find yourself at this prompt you can find a list of available commands by hitting the tab key.

The first thing that you are going to want to do in any of these cases is check and make sure that your root directive is correct. To do this, at the grub prompt, use the find command to locate the GRUB configuration file. Your search would begin something like this:

grub> find (hd0,0)/grub/grub.conf

where hd0,0 is the 1st hard disk and the 1st partition on the hard disk. Repeat the process using the various partitions on the 1st disk (hd0,1 hd0,2) and so on until you find the configuration file. If the partition is not found you will get an error:

Error 15: File not found

Once you have found the GRUB configuration file check it’s location against what the boot loader is showing. You can check the contents of the file by using the cat command:

grub> cat (hd0,0)/grub/grub.conf

Another way to find the same information is to locate the stage1 boot loader file:

grub> find /grub/stage1

You will see output specifying the /boot partition:

(hd0,0)

Perhaps the most simple way to get this information is to simply type root at the prompt:

grub>root
(hd0,0) : Filesystem type is ext2fs, partition type 0×83

Command completion also works from the GRUB command line. If you don’t remember the name of the kernel file type kernel / and press the tab key. This will show you the available files in the boot directory. The same holds true for the initrd file.

To sum all of this up and get your machine booted, at the GRUB configuration file type c for the GRUB command line. You should be at the grub> prompt.

Start by issuing the root directive as described above. This will set up your /boot partition. Now setup your kernel command line as described above. Remember that you can use command completion as this is a long line. At the prompt type:

grub> kernel /vmli (hit the tab key to complete the vmlinuz line).

You will also need the root=/your/root/partition directive on this line for Linux to boot. Last setup the third line by typing initrd which specifies the initial RAM disk.

grub> initrd /init (hit the tab key to complete the initrd line)

Now enter boot at the command prompt and your Linux machine should boot if you have the correct parameters.

Of course you could possibly prevent all of this by keeping a backup copy of the GRUB configuration file in the root’s home directory at /root.

-j

Sep 11 2008   12:36AM GMT

Troubleshooot your Linux boot process with GRUB



Posted by: John Little
Linux, /boot, grub, /root, grub.conf, menu.lst

Red Hat and subsequently Fedora and CentOS use the the GRUB (Grand Unified Boot Loader) to initialize the kernel and boot into Linux. I’m going to look at some of the common error messages possible when booting Linux and how to edit the GRUB boot loader to test and fix the errors.

GRUB has 6 basic editing commands:

b=boot the currently listed operating system
d=delete the current line
e=edit the current line
a=append a parameter to GRUB
o=create an empty line underneath the current line
O=create an empty line above the current line

These are the commands with which I will initially be working to access the grub configuration file.

After you boot to the GRUB menu screen highlight the line the Linux version that you want to edit. I like to use e so that I can choose which line that I want to edit.

On Red Hat and it’s derivatives you will usually see three lines at this point:

root
kernel
initrd

While any of the three could need editing to pass a parameter to the kernel you will want to use the kernel line. Highlight this line and press e to edit. Move to the end of the line to add a parameter. The kernel has many parameters that you can add here. I will use some of the more commonly used.

Booting into a different runlevel is probably one of the most common tasks of a Linux administrator. The Red Hat kernel has 7 parameters that you can use to boot to the runlevel that you want. These are 1, single (or s), emergency, 2, 3, 4, or 5. If you add single or s to the end of this line you will boot into single user mode. If you boot into runlevel 0 or 6 you will either halt or reboot your machine.

Another common area that not only administrators but users as well find themselves requiring is the VGA setting. Occasionally on updating a video driver or for various other reasons your machine may continue booting but only showing a black screen without any output. A possible way to overcome this so that you can see the output and at least get to runlevel 3 is vga=ask.

Some other commonly used parameters are selinux=[0|1] where 0 disables selinux, acpi=[force|off|noirq|ht|strict] and mem=n[KMG].

The ACPI option controls parameters that the Advanced Configuration and Power Interface (ACPI) subsystem can use. This is the main option for the Advanced Configuration and Power Interface (ACPI). The values are:
force: Force ACPI to be enabled. Can be used to override the kernel configuration option that disabled it.
off: Disable ACPI. Can be used to override the kernel configuration option that enabled it.
noirq: Prevent ACPI from being used for IRQ routing.
ht: Run only enough of the ACPI layer to enable HyperThreading on processors that are capable of it.
strict: Make the ACPI layer be less tolerant of platforms that are not fully compliant with the ACPI specification.

The mem option forces a certain amount of memory used by the kernel. When
used with the memmap= option, physical address space collisions can be avoided. Without the memmap= option, this option could cause PCI devices to be placed at addresses that belong to unused RAM. n specifies the amount of memory to force and is measured in units of kilobytes (K), megabytes (M), or gigabytes (G).

That covers some basics kernel parameters, how to access and edit them. You will find these most useful generally on a new install or after adding new hardware that is either not detected or acting properly.

If you want to see more on the various kernel options and parameters install the kernel-doc package. The documentation can then be found under /usr/share/doc/kernel-doc-2.6.18/Documentation on recent Red Hat and CentOS versions.

Next post I’ll get into some of the error messages that are common when you Linux machine refuses to boot.

-j