GRUB stands for GRand Unified Bootloader. It's meant as a alternative to the widely-used LILO (LInux LOader). In many ways, it is superior to LILO. One such advantage of GRUB is that if the configuration file is incorrect or corrupted, you may still be able to boot your system. It does require a basic familiarity with using GRUB in Interactive mode. This tip is meant to help you do that.Situation: You boot and you get some error about loading a GRUB kernel and then a black screen with this text (or similar):
Quote
GRUB version 0.93 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ]grub>
First of all, you need to know how GRUB numbers drives and partitions. Hopefully, Bruno doesn't mind me stealing this from one of his posts:
Quote
Grub uses its own naming structure for drives and partitions, in the form of (hdn,m), where n is the hard drive number, and m the partition number, both starting from zero. This means, for instance, that partition hda1 is (hd0,0) to Grub, and hdb2 is (hd1,1). In contrast to Linux, Grub doesn't consider CD-ROM drives to be hard drives, so if you have a CD on hdb, for example, and a second hard drive on hdc, that second hard drive would still be (hd1).
Note that GRUB doesn't care if it's SCSI or IDE, it still starts with
hd.So here's how to boot a kernel with that > prompt:You need to specify the GRUB "root". Root can mean a lot of things in Linux, but in this case GRUB just needs to know the drive where the kernel is that you wish to boot. The following commands use this information. Here's how you specify the "root" (note that I'm showing grub> for clarity, don't enter it):(don't hit <enter> at the end... yet)grub> root (hdand then hit the <tab> key, GRUB will stick in a zero if you only have a single hard-drive or give you a list of drives if you have more than one. This first number is referring to a physical hard drive, not just a partition. Enter a comma and then hit <tab> again and you'll see a list of partitions to choose from next like this:
Quote
Possible partitions are: Partition num: 0, Filesystem type unknown, partition type 0x7 Partition num: 2, Filesystem type unknown, partition type 0x83 Partition num: 3, Filesystem type unknown, partition type 0x4 Partition num: 4, Filesystem type is fat, partition type 0xb Partition num: 5, Filesystem type unknown, partition type 0x82 Partition num: 6, Filesystem type is reiserfs, partition type 0x83
This can help you choose the partition that has the Linux kernel on it if you're not sure. Pick a number and then type the remaining parenthesis and <enter> so a complete
example line would look like this:grub> root (hd0,5)Now that's choose the kernel. If we're not sure the kernel is here, this next command will show us that, in which case you'd go back and choose another partition (or drive and partition if applicable in your situation):(don't hit enter after this, yet)grub> kernel /boot/Hit <tab> again and you'll get a list of the kernels that grub sees on that partition in /boot. Isn't this cool? If it can't find any kernels, make sure you entered /boot after kernel and then go back to the previous root command and try a different one. Remember that GRUB counts beginning at zero so hda6 would show up in grub as (0,5). Assuming you find a kernel, type the unique letters to it (you can hit <tab> to finish it) and then enter a space to append "root=" on the end with the location of the Linux root directory. This root is the regular meaning of root in that it refers to where Linux normally mounts the "/" filesystem. Unless you've custom partitioned, it'll be the same drive and partition as where /boot is. This time you have to give it the term Linux uses to refer to that drive like "/dev/hda7". I don't think auto-complete works here so you'll have to be specific. Here's a
sample line where /boot and / are on the same partition:grub> kernel /boot/vmlinuz root=/dev/hda6Note that /dev/hda6 and (hd0,5) refer to the
same partition.The next command may or may not be optional depending on whether your system needs an initrd file to boot. If you don't think you need it, just skip this part:(don't hit <enter> yet)grub> initrd /boot/Hit <tab> again to show eligible initrd files and type enough letters to auto-complete the rest with another <tab>. The final
example line will look similar to this:grub> initrd /boot/initrdNote the above settings on some paper so you know what they are. Now the last command:grub> boot(hit enter)If you get a kernel panic and a blurb about needing a root, then you probably forget to add the root= part on the end of the kernel line, and if you get an error message referring to initrd, then you need this line. This is also why you should write down the settings you use. Reboot, and try again.Once you've booted you should edit GRUB directly (the above changes didn't install anything, it just got you running) or use your distributions boot loader configuration tool (in SuSE, I use the one in YaST under System) to edit grub using the parameters above.Hopefully this is helpful to people and I haven't made any bad typos. Corrections, suggestions or criticism is appreciated.