Jump to content
Scot's Newsletter Forums
Sign in to follow this  
linuxdude32

What to do when you get the GRUB prompt

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):[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>[/quote]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).[/quote]Note that GRUB doesn't care if it's SCSI or IDE, it still starts with [b]hd[/b].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[/quote]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 [b]example[/b] 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 [b]sample[/b] 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 [b]same[/b] 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 [b]example line[/b] 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.

Share this post


Link to post
Share on other sites
Hi JasonThanks dude ! . . And no I don´t mind !! :whistling: :DDo you think there is anything I should add to [url="http://forums.scotsnewsletter.com/index.php?act=ST&f=14&t=503&st=229"]Tip[/url] 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.

Share this post


Link to post
Share on other sites
[quote name='Bruno' date='Jan 10 2004, 05:06 PM']Do you think there is anything I should add to [url="http://forums.scotsnewsletter.com/index.php?act=ST&f=14&t=503&st=229"]Tip[/url] 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.[/quote]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!

Share this post


Link to post
Share on other sites
Thanks Jason, copied this one and printed.Much appreciated !

Share this post


Link to post
Share on other sites
Thanks for info.Hopefully Scot and Arena have nice backups of DB in case something goes wrong.I'd hate to see all this nice info gone :whistling:

Share this post


Link to post
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:

Share this post


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

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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 [b]however[/b] configuring was troublesome so I went back to lilo.I decided to give GRUB another try [b]I like this lazy man's bootloader ie no copying of vmlinuz files required;no rescue CD etc[/b] :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

Share this post


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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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!

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[quote name='moon' post='243493' date='Jan 4 2008, 03:33 PM']u can try to edit/correct 2 more files:/etc/fstab and /etc/mtab (correct hdax ref. to /)[/quote] . . . 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

Share this post


Link to post
Share on other sites
[quote name='Bruno' post='243506' date='Jan 4 2008, 01:10 PM']. . . 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[/quote]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"

Share this post


Link to post
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:

Share this post


Link to post
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

Share this post


Link to post
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.

Loading...
Sign in to follow this  

×
×
  • Create New...