Jump to content

What to do when you get the GRUB prompt


linuxdude32

Recommended Posts

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):

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:
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:
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.
Link to comment
Share on other sites

Hi JasonThanks dude ! . . And no I don´t mind !! :whistling: :DDo you think there is anything I should add to Tip or shall I just put a link to this post at the end ??<_< BrunoPS: Your PM box is blocked . . . I can not send you any because it refuses to take them and gives the message that your box is full.

Link to comment
Share on other sites

Do you think there is anything I should add to Tip or shall I just put a link to this post at the end ??PS: Your PM box is blocked . . . I can not send you any because it refuses to take them and gives the message that your box is full.
It doesn't seem simple enough for a tip and would probably just confuse beginners to Linux. I'm thinking just leave it here and anybody doing a search for grub would find it (assuming they were in SNLF, of course). A link from your tips would enable more people to find it if their system didn't boot all of a sudden. I only saw the one section you had on GRUB. Did you have another one that covered this already?As for my mailbox, I suddenly saw the message the top saying it was full! I had no idea, but it's cleaned up now!
Link to comment
Share on other sites

Thanks JasonWish I would have had this the other day. But I got it going once everyone in the forum jumped in and helped me. BTW I installed the 2.6 0 kernel in SuSE 9.0 pro But I will save that for another post.Mel :whistling:

Link to comment
Share on other sites

Guest LilBambi

Thanks Jason! Having always used LILO in the past, it was great to read about GRUB and the step by step was great! Between this and Bruno's Tips about GRUB, I think all will be able to get the help they need with it.:whistling:

Link to comment
Share on other sites

Thanks guys! You're all so encouraging. You're welcome to visit PLUG anytime. It'd be easier to do presentations if I got compliments like that all the time. Might go to my head, though! B) Thanks for linking it, Bruno!

Link to comment
Share on other sites

Excellent, Jason, thanks! Have always used LILO - without any problems - but I've got an "old" hdd laying around, so will use your post and Bruno's tip, in an experiment...I've always wanted to "explore" GRUB.

Link to comment
Share on other sites

  • 5 months later...

Jason must admit when I first read this tip a few months ago it seemed like gibberish.I have always used lilo.I did an install of Fedora a few months ago decided to try GRUB and liked it however configuring was troublesome so I went back to lilo.I decided to give GRUB another try I like this lazy man's bootloader ie no copying of vmlinuz files required;no rescue CD etc :thumbsup: :D configuring stumped me however ;) I remembered this post and tried it and after a few attempts got my 3 OSes to boot from GRUB :w00t:Thanks Jason for this very excellent tutorial :w00t: ^_^ P.S. in the more recent versions of GRUB at least those I've tried the root option doesn't seem to be used ie I only had to configure kernel and initrd lines. :o

Link to comment
Share on other sites

  • 1 year later...

hi there,i installed suse 9.1 personal in VMWare 4.5 (I put HD = 50 GB for this VM)then put in some stuff, it was working Ok until I felt the system was really slow. Then power off the VM, then only get this grub prompt.I've tried: > root (hd0,0) --> I only have 1 hdFilesystem type unknown, partition type 0x82> kernel /boot/Error 17: Cannot mount selected partitionwhat should I do?thanks.

Link to comment
Share on other sites

Hi FerryWelcome to the forumI never tried VMware so I can not really advise you about it . . . but it seems to me that once you installed it in VMware you need VMware to run it every time you want to boot it. Maybe installing SUSE on its own partition without VMware will be a better idea.Maybe we should start a new topic about this so it will get more attention. So if you want me to split it off let me know and I will do that for you.o:) Bruno

Link to comment
Share on other sites

Thanks Jason, great job, after reading your GRUB tip I feel that I could actually use GRUB, and add other OS's to it.It's my understanding that lilo is a 16 bit bootloader and grub is a 32 bit bootloader. And with mass adoption of 64 bit computers just a few years away I suspect that grub will the bootloader most distributions will use. Probably be real easy to port grub to 64 bit.

Link to comment
Share on other sites

"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.">seen up the thread+++++++++++++I gotta jump in here with a detail that commonly kills grub; it natively gets its info about drives from bios -- the first drive that bios finds in its POST search becomes grub's hd0, the second becomes hd1, third hd2, etc., etc. We'd like to think that grub's ordering follows some absolute natural ordering scheme like /dev/hda, /dev/hdb, /dev/sda, etc ... BUT, any modern mobo will allow the user to set a custom boot order in cmos setup -- and thus that /dev/sda might very well become bios #1 'find', and thus grub's hd0. Change boot order in bios, and every menu.lst on your machine is instantly wrong. This is the one place that lilo has a better design. [and so has loadlin.exe, the booter I use here] There is a fix for this -- the /boot/grub/device.map file -- where absolute assignments are made. Sadly, many distros don't implement that file -- and hardly any publish any information about it; after you edit your menu.lst file, you must also check that it doesn't disagree with an existing device.map file.There's another problem I haven't yet figured how to solve -- and that is giving grub in manual mode all of those kernel parms that don't match any known keyword in grub. Onward!

Link to comment
Share on other sites

Thanks Jason!I too printed your tips in case I am on a machine that agrees with Grub. Unfortunately each time I tried to install a distro I got the dreaded Grub 1.5 (or something similar) with an Error 16 (or was it 17?) and there was nothing I could do to fix it. But for a more recent machine I will definitely give Grub a try and use your tips.Thanks again!

Link to comment
Share on other sites

  • 2 years later...

Hi, If grub does still does not install, u can try to edit/correct 2 more files:/etc/fstab and /etc/mtab (correct hdax ref. to /)That is what i had to do when i imaged an ext3 partn.(RIP) from hdc1 to hda1.Regards

Link to comment
Share on other sites

u can try to edit/correct 2 more files:/etc/fstab and /etc/mtab (correct hdax ref. to /)
. . . sorry to interrupt . . but you should not change the /etc/mtab file, it gets dynamically build and only reflects what is mounted at a certain time. So changes in the /etc/fstab will automatically be reflected in /etc/mtab.:thumbsup: Bruno
Link to comment
Share on other sites

. . . sorry to interrupt . . but you should not change the /etc/mtab file, it gets dynamically build and only reflects what is mounted at a certain time. So changes in the /etc/fstab will automatically be reflected in /etc/mtab.:D Bruno
You r right Bruno ( provided the pcboots at least once).Here is what happened in my case:1.After restoring the image, i get a non-responding Grub prompt (blinking cursor after :whistling:...only cntrl-alt-del works.2.I did initial boot with rip cd and then continued the boot via the restored image.3.Boot failed midway (kernel panic)..i did not know about fstab at that moment.4.So i try to reinstall grub (boot cd, mount partn, edit files, chroot, execute script grub_install )....failure. Finally, made the change to fstab.5.Tried grub install again. Failure.6.Only when mtab file was edited did grub install. RegardsHey i don't know how that smiley creeped in...it should read as " after the letter "B" of GRUB"
Link to comment
Share on other sites

Glad you got it fixed Moon . . . :D . . . . must have been a blib why mtab did not get updated with the new info automatically ;):whistling: BrunoPS: About the smiley you got: if you type a "B" and a ")" without space between them you do get the secret code for :happyroll:

Link to comment
Share on other sites

" must have been a blib why mtab did not get updated with the new info automatically " Blib means a one off event?I think "why mtab did not get updated with the new info automatically " is bec. i did not give a chance for pc to boot properly i.e. After step 4, step 2 (boot:root=/dev/hda1) should have been the next step again.Just for completeness...step 4...."edit files" refer to grub_install script (install_device=(hd0,0), menu.lst, device.mapI will come back here if i confirm a peculiar behaviour of grub...it sort of "remembers" the HD on which it was installed (some bit for bit copy i did of slack11 partn. in RPM on another HD)Regards

Link to comment
Share on other sites

Hi NoonI think maybe your problem is that you restored from an image . . . and depending on the distro ( example Ubuntu ) the use of UUID's numbers ( Universally Unique Identifier ) in the fstab where other distros would refer to the partitions simply as /dev/hda5. Now, the slightest little change to the HD will make the UUID number to change and make the fstab useless.Does this make sense ? . . Could that be the cause of your problem ?B) BrunoPS: You can simply replace the UUID by the old-skool /dev/hdaX

Link to comment
Share on other sites

I've got a couple of links that you might like to check out if you are having trouble with GRUB.The first one is: "Grub From the Ground Up", and the link is:www.troubleshooters.com/linux/grub/grub.htmThe next one is: www.linuxforums.org/forum/linux...ng-boot-problems-grub2nd-edition.htmlSometimes comparing examples from different perspectives and descriptions, can probably clarify a fix to a perplexing problem. Cheers!

Link to comment
Share on other sites

Cluttermagnet

Wow! I'm going to have to read and reread the last 6-10 posts for fuller understanding. At the moment, it sounds to me like images can be tricky in Linux. OTOH I have yet to make even my first Linux image on any machine. At least I don't remember doing so.Also, I seem to remember Bruno advising that it is often easiest to just wipe and reinstall your OS, in the case of Linux? After nearly a year running Linux OS's, I think I am starting to see the reality of that. It's not all that hard to reinstall. But I am really fond of the power of drive imaging in the Windows world.Under Windows, drive images are fairly close to a 'cure all'- say if you get a destructive virus or trojan or get root kitted- or if you just crash and burn the OS. Perhaps not so much in Linux. Anyway, it sounds like any Linux image becomes problematic- or useless- if you later* change boot order in BIOS, or* add or remove devices, anything affecting fstab?And it now sounds to me like they can really* confuse grub.Yes, there are now those UUID numbers. I think I much preferred the older /dev/hdaX approach.I certainly learned the hard way to leave drive partitions alone if I want to keep my Linux OS's running. Heh! :thumbsup: But then it is so easy to reinstall and update. For me, there are also the minor additional hassles of having to set up bash scripts to take care of No Caps Lock and mounting Zip drives, and such. But that gets easier and easier as I get more practiced at doing it.

Edited by Cluttermagnet
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...