30 December 2010

The GRUB Command Line

If you see a GRUB command line, you may feel lost. To see a list of available commands, press the TAB key at the grub> prompt.

Some trial and error may be required. You should be able to find all detected hard drives on a standard PC from the BIOS menu (SCSI drives can be a different story). Assuming you have just one, you can use the find command to identify the partition with the GRUB configuration file. For example, to find grub.conf on this particular system, start with the following command:
grub> find (hd0,0)/grub/grub.conf
This returns an "Error 15: File not found" error message. Repeat this process with the other partitions on this drive,
grub> find (hd0,1)/grub/grub.conf
grub> find (hd0,2)/grub/grub.conf
grub> find (hd0,3)/grub/grub.conf
grub> find (hd0,4)/grub/grub.conf
and so on, until you see output associated with your partition, such as:
(hd0,4)
In this case, the /boot directory is on the fifth partition on the first hard drive. Just to confirm, use the cat command to read the contents of the GRUB configuration file:
grub> cat (hd0,4)/grub/grub.conf
Now use these commands from the GRUB configuration file to boot Linux from the grub> command line. But what if your GRUB configuration file is missing?

Note that a shortcut is available. From the grub> command line, look for the stage1 boot loader file. The command is simple:
grub> find /grub/stage1
If the stage1 boot loader file is still there, you'll see output specifying the partition with the /boot directory, such as:
(hd0,4)
But wait, it can be even simpler. Just run root at the grub> command line:
grub> root
(hd0,4): Filesystem type is ext2fs, part type 0x83
Command completion works from the GRUB command line. For example, if you don't remember the name of the Kernel file, type kernel / and then press the TAB key to review the available files in the /boot directory.


See Also:


RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)




biOos

No comments: