when relevant content is
added and updated.
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:
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:
Perhaps the most simple way to get this information is to simply type root at the prompt:
(hd0,0) : Filesystem type is ext2fs, partition type 0x83
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.