Results 1 to 1 of 1
NOTE : if you read the tutorial and are still experiencing difficulties and would like help, you are asked to start a new topic on the forums . Please do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-15-2004 #1
Howto solve boot problems with Grub
NOTE: if you read the tutorial and are still experiencing difficulties and would like help, you are asked to start a new topic on the forums.
Please do NOT reply to this thread to ask a technical question. Replies to THIS thread should be corrections and enhancements on the tutorial/howto only.
Thanks in advance for your co-operation.
Please note this document has been superceeded by Version 2 available here:
I wrote this as an aid to people who are having some problems getting started with Linux. It has not been written to replace the GRUB documentation, which can be found here :- GNU GRUB Manual 0.97 or by entering "info grub" on your Linux PC.
I have tried to address two common problems that users bump into with Grub, these are :-
1) I've just loaded / upgraded Windows and now I can't get into Linux!
2) I don't know why, but all I get now is a "grub>" prompt when I try and boot my PC!
The examples come from my PC, which runs Fedora Core 1 and has two separate IDE attached hard disks, but don't let any of this put you off, as you'll find that the commands will work just as well with your PC.
If your PC has SCSI hard disks, then replace the "hd" with "sd" in the commands below.
Windows has stopped me being able to boot into Linux
This problem (1) is caused by Uncle Bill's operating system deliberately overwriting an area of your hard disk known as the Master Boot Record (MBR). The MBR is the bit of your hard disk that holds the "where is the operating system" information. It is the MBR that your PC hands control over to, at boot up time, if it cant find an operating system in your floppy disk drive or your CD-ROM drive (The order that your PC looks for an operating system is set-up in the BIOS. Press either the Del or the F2 key to access your BIOS setup when you boot).
The easiest way out of this fix is to boot from the Linux rescue floppy diskette that you made when you installed Linux. If you remembered to create one, put it into your floppy diskette drive and boot your PC. When you get your Linux prompt, follow the instructions below in the section titled "re-installing GRUB".
If you 'forgot' to create a rescue diskette, read on.
What we have to do is get GRUB back onto the MBR, so that we can get the familiar GRUB menu of operating systems. To do this we must first wrest control away from Windows and back to GRUB. To do this we need two files which are available from one of our moderator's (Dolda2000) web site.
Download these onto your PC (or any PC for that matter) and run the rawrite program to copy the grub.img file onto a pre-formatted floppy diskette (note, once this has been done, you will not be able to read that diskette. This is how it should be).
Now, boot your PC with this floppy diskette. You will get a text based screen looking something like this :-
GRUB version 0.92 (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>
grub> find /boot/grub/stage1 (hd0,1)
As you can see, the counting, here, is done starting at zero. So the first hard disk is "hd0" ,second "hd1" ,third "hd2" and so on. Your first partition is "0" , your second "1" , your third "2" and so on.
Why is this important? Well, we need to know where the Grub files live (and stage1 is one of these files) so that we can do the next command. If it helps you at all, you can think of (hd0,1) as being rather like "C:" in Windows.
Now that we know where grub lives - (hd0,1) in our example PC - we can get our normal Grub menu back by entering :-
grub> configfile (hd0,1)/boot/grub/grub.conf
You will now be presented with your normal, familiar Grub menu. Select and boot into Linux, and then re-install Grub onto your MBR, using the following steps.
Now that your safely back into Linux, you'll want to get Grub back onto your hard disk's MBR. This is simply done by opening a terminal window as root (or as your normal user and entering 'su -' to become the root/super user) and enter the "grub-install" command. This command takes a single parameter, which is the name of the hard disk that you want Grub to be installed on. Now that we are in Linux, the hard disk naming convention is no longer the (hd0,1) format that we used in grub, but the one that Linux uses. This starts with /dev/ and is followed by 'hd' and then a letter from 'a' to 'd' .
So, if you normally boot from your first (and perhaps only) hard disk, you will use "/dev/hda". If you normally boot off your second hard disk you will use either "/dev/hdb" or "/dev/hdc" or /dev/hdd" depending upon which IDE cable it is plugged into and whether it is the master or slave on that cable (a and b are master and slave on IDE1 ,while c and d are master and slave on IDE2).
[root@localhost nerderello]# /sbin/grub-install /dev/hda Installation finished. No error reported. This is the contents of the device map /boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install'. # this device map was generated by anaconda (fd0) /dev/fd0 (hd0) /dev/hda (hd1) /dev/hdc
And that's it. You now have Grub back where you want it. Now, create a Linux rescue diskette, so that you won't have to go through that little lot again (
use the "mkbootdisk" command to create one).
I just get a grub> prompt
This problem (2) is a little more worrying. You can try getting the usual Grub menu back up by doing the "find" and then the "configfile" commands (see above), but these may not work. So here is how to boot Linux from the "grub>" command.
First we need to find out where the kernel lives (find command again), then we need to set "root" to its proper device, then we need to tell Grub which kernel to use and then (optionally) which initrd to use (note. the word "root" here is used to mean the starting point, rather than anything to do with the root user).
The first bit uses the "find" command to find a file called /boot/grub/stage1 :-
grub> find /boot/grub/stage1 (hd0,1)
Once you know the hard disk partition that your kernel lives on, you can go about setting your root hard disk.
The root will be on the same hard disk and partition that we found the Grub file /boot/grub/stage1 on. So, in the examples we have been doing so far, the "root" (i.e. the hard disk that has the "/boot/" directory on it) would be on (hd0,1). To set this we enter the root command :-
grub> root (hd0,1) Filesystem type is ext2fs, partition type 0x83
Now it's time to tell Grub what the kernel file is called and where it is. For this we use the "kernel" command. If you know what your kernel is called and where it is you can simply type it in. If you're not sure, and let's face it some of them have long names, we can type part of the kernel command and then press the Tab key, Grub will try and help out.
grub> kernel (hd0,1)/boot/ Possible files are: grub System.map-2.4.22-1.2115.nptl vmlinuz boot.b chain.b os2_d.b System.map vmlinuz-2.4.22-1.2115.nptlcustom System.map-2.4.22-1.2115.np tlcustom initrd-2.4.22-1.2115.nptlcustom.img module-info kernel.h vmlinuz-2.4.2 0-8custom System.map-2.4.20-8custom initrd-2.4.20-8custom.img vmlinuz-2.4.20-8c ustom.old System.map-2.4.20-8custom.old initrd-2.4.22-1.2115.nptl.img config-2. 4.22-1.2115.nptl vmlinux-2.4.22-1.2115.nptl vmlinuz-2.4.22-1.2115.nptl initrd-2 .4.22-1.2149.nptl.img System.map-2.4.22-1.2149.nptl config-2.4.22-1.2149.nptl v mlinux-2.4.22-1.2149.nptl vmlinuz-2.4.22-1.2149.nptl grub> kernel (hd0,1)/boot/vmlinuz-2.4.22-1.2115.nptl [Linux-bzImage, setup=0x1400, size=0x12c945]
NOTE Certain distributions (Mandrake 9.2 for one) require that you also enter the two parameters "ro" (read only) and "root=/dev/hd??" on the same line as the kernel command (where the question marks are the hard disk letter and the partion number. Here we are using the Linux naming convention, which is described above in the "re-installing Grub section"). So, if in our examples we had such a distribution we would have to enter :-
For Mandrake 9.2 grub> kernel (hd0,1)/boot/vmlinuz-2.4.22-10mdk ro root=/dev/hda2 [Linux-bzImage, setup=0x1400, size=0x12c945]
If you do need an initrd, you tell Grub by using the "initrd" command. The name of the initrd file must match that of your kernel.
grub> initrd (hd1,0)/boot/ Possible files are: grub System.map-2.4.22-1.2115.nptl vmlinuz boot.b chain.b os2_d.b System.map vmlinuz-2.4.22-1.2115.nptlcustom System.map-2.4.22-1.2115.np tlcustom initrd-2.4.22-1.2115.nptlcustom.img module-info kernel.h vmlinuz-2.4.2 0-8custom System.map-2.4.20-8custom initrd-2.4.20-8custom.img vmlinuz-2.4.20-8c ustom.old System.map-2.4.20-8custom.old initrd-2.4.22-1.2115.nptl.img config-2. 4.22-1.2115.nptl vmlinux-2.4.22-1.2115.nptl vmlinuz-2.4.22-1.2115.nptl initrd-2 .4.22-1.2149.nptl.img System.map-2.4.22-1.2149.nptl config-2.4.22-1.2149.nptl v mlinux-2.4.22-1.2149.nptl vmlinuz-2.4.22-1.2149.nptl grub> initrd (hd1,0)/boot/initrd-2.4.22-1.2115.nptl.img [Linux-initrd @ 0x3c8000, 0x27dcb bytes]
If you mistype the name, all that happens is that Grub gives you an error message :-
grub> initrd (hd1,0)/boot/initrd-2.4.22-1.6666.nptl.img Error 15: File not found
If you're still having problems here are a few tips
If your Grub config file is there, but not readable at boot up, you may still be able to find the names of your kernel and inird by looking at its contents. You do this with the "cat" command, like so :-
grub> cat (hd0,1)/boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You do not have a /boot partition. This means that # all kernel and initrd paths are relative to /, eg. # root (hd0,1) # kernel /boot/vmlinuz-version ro root=/dev/hda2 # initrd /boot/initrd-version.img #boot=/dev/hda default=0 timeout=10 splashimage=(hd0,1)/boot/grub/splash.xpm.gz title Fedora Core (2.4.22-1.2149.nptl) root (hd0,1) kernel /boot/vmlinuz-2.4.22-1.2149.nptl ro root=LABEL=/ rhgb initrd /boot/initrd-2.4.22-1.2149.nptl.img title Fedora Core (2.4.22-1.2115.nptlcustom) root (hd0,1) kernel /boot/vmlinuz-2.4.22-1.2115.nptlcustom ro root=LABEL=/ rhgb initrd /boot/initrd-2.4.22-1.2115.nptlcustom.img title Fedora Core (2.4.22-1.2115.nptl) root (hd0,1) kernel /boot/vmlinuz-2.4.22-1.2115.nptl ro root=LABEL=/ rhgb initrd /boot/initrd-2.4.22-1.2115.nptl.img
The only other Grub command that I'm going to mention here is the "help" command
grub> help blocklist FILE boot cat FILE chainloader [--force] FILE clear color NORMAL [HIGHLIGHT] configfile FILE device DRIVE DEVICE displayapm displaymem find FILENAME geometry DRIVE [CYLINDER HEAD SECTOR [ halt [--no-apm] help [--all] [PATTERN ...] hide PARTITION initrd FILE [ARG ...] kernel [--no-mem-option] [--type=TYPE] makeactive map TO_DRIVE FROM_DRIVE md5crypt module FILE [ARG ...] modulenounzip FILE [ARG ...] pager [FLAG] partnew PART TYPE START LEN parttype PART TYPE quit reboot root [DEVICE [HDBIAS]] rootnoverify [DEVICE [HDBIAS]] serial [--unit=UNIT] [--port=PORT] [-- setkey [TO_KEY FROM_KEY] setup [--prefix=DIR] [--stage2=STAGE2_ terminal [--dumb] [--no-echo] [--no-ed terminfo [--name=NAME --cursor-address testvbe MODE unhide PARTITION uppermem KBYTES vbeprobe [MODE]
I hope that you have found this of some use.
Last edited by oz; 11-30-2007 at 01:53 AM. Reason: updated URL to version 2
Use Suse 10.1 and occasionally play with Kubuntu
Also have Windows 98SE and BeOS