GRUB HOWTO and trouble-shooter
Please do not post a question on this thread.
this post contains important change on inode size 256 for ext2 ext3 ext4
The solutions are
do not use a old live cd that has an old grub on it,
use a live cd that is known to have this fixed,
....currently sidux live cd or dvd is good
(b) change to lilo (grrrrr)
(c) change from ext format to xfs etc
This is document is GPL. Please do backups. Do at your risk.
(a) It can boot very large kernels over a number of floppies
(B) It can be burnt to cdr with your own compiled kernel or your distros
(b) Grub troubleshooting is easier with inbuilt commands especially the use of the tab key
(c) You install grub once then edit the menu.lst file without having to re-run grub
My examples may need you to modify if your /etc/fstab is different from mine. You may need /boot/vmlinuz instead of /vmlinuz for linux users.
GRUB is a boot loader normally installed in your Master Boot Record (MBR) to boot an operating system. I am only concerned with Linux and Microsoft types. Linux is Trade Marks of Linus Torvalds and Windows or Microsoft are Trade Marks of Microsoft Corporation. I abbreviate Microsoft as MS
BACKING UP MBR and RESTORING
Now a link to a WIKI file here
darin3200 for help with my splashimage howto
oneandoneis2 for inspiring me to look at Grub's command editor at boot. I did not do so initially because I am so good my grub was always successful. (I blush)
Luis R. Rodriguez for his original work on splashimage.
zatka for those who want to keep NTLDR (windows in mbr) but use grub on a partition
thegreedyturtle provides the partition error for SUSE
johnewing found another FC fix
samaujs for correcting my syntax for the windows map brackets needs a gap
motub for those who want to wind back to windows
thom for links on suse and solution
BIG Al for report on Mdk
doug_s for link on Mdk
KohlyKohl for his bios LBA suggestion
vectordrake confirms w98=xp=2000 Microsoft share configs
Carla Schroder for her loop info to test an iso b4 burning it
michaelk to mentioning MS needs to be on primary partiton
Not now, John! for flash media instructions
kilgortrout for UUID stuff
homey for LVM stuff
my APOLS to any who posted earlier or who I have missed.
WHERE TO GET GRUB AND REFERENCES
Most distros can handle .rpm files so try http://fr2.rpmfind.net/linux/rpm2htm...mit=Search+...
OR try .tar files at ftp://alpha.gnu.org/gnu/grub/
Debian .deb files are at
Local hard drive files
/boot/grub/menu.lst (lst is short for list).....man grub...info grub
Backup files should be in /usr/local/share/grub/i386-pc. Search if they are not.
On line manual at
Be aware that grub2 is in development and is mentioned here
HOW TO INSTALL THE SOFTWARE
Note this does not overwrite your mbr only makes the file available.
KDE users in Konqueror-Click on the rpm file and kpackage should start then click on the rpm file and
click on install marked button. See the help in KDE if any problems.
Backup stage 1 etc files MAY be in /usr/local/share/grub/ or /lib/grub/
GRUB counts drives detected, by counting from ZERO like this 0,1,2 etc.
So drives are (hd0) (hd1) (hd2) etc
Partitions, as listed in your /etc/fstab file for IDE types are
/dev/hda1 /dev/hda2 ..../dev/hda11 etc OR /dev/sda1 /dev/sda2.....etc for SCSI and SATA types.
In GRUB speak are (hd0,0) (hd0,1) (hd0,2) etc
Notice a simple rule is to subtract ONE to convert to GRUB speak. And both IDE or SCSI or SATA become (hdX).
eg /dev/sda15 becomes (hd0,14)
Floppy drives have the same count style but are (fd0) (fd1) etc.
Drives or partitions have to be in simple brackets and have no gaps even if a comma is used.
eg (hd0,0) not ( hd0, 0 )
How do I check what GRUB will detect?
Open /boot/grub/device.map with your favourite text editor or web browser. If you have no device.map file it is not a problem unless you have a scsi device that Grub is having trouble with. And maybe raid but I don't have raid so don't know.
KNOW YOUR /ETC/FSTAB FILE
I suggest you keep a copy
If /etc/fstab has an entry like this
/dev/hda1........ /boot.........and some other stuff.
GRUB speak for this /boot partition is (hd0,0)
If you can't see /boot listed, then its on the same partition as /..... it is a SUB-FOLDER to /.
eg /dev/hda5........../.............and some other stuff.
GRUB speak is (hd0,4)
The boot partition or sub-folder will normally have a vmlinuz file (the kernel) maybe a initrd image file and normally these files link to another vmlinuz or initrd file like vmlinuz-2.6.7 and you may have other entries due to re-compiles you have done. More on these files discussed in the menu.lst examples.
The fstab tells you whether to use on the kernel (or initrd) line a structure like this
kernel /boot/vmlinuz etc OR
kernel /vmlinuz etc
Well if you have a separate /boot partition when you read the next section you will have got into it so relatively speaking the files will show up as /vmlinuz /initrd etc
WHEREAS if you have /boot as a sub-folder to / partition THEN you need to navigate into a sub-folder so its /boot/vmlinuz
Some computers have trouble reading a linux /boot partition that exceeds cylinder 1024. GRUB supports Logical Block Address (LBA) so you should not have a problem. You may need to change or upgrade your bios and then enable lba setting in your bios.
This tutorial uses root command. eg
The ROOT comnand defines the search path for what happens next. For linux users, it defines the /boot partition or the /boot sub-folder of your / partition as per your /etc/fstab file For MS users it defines the search path for the MS bootloader.
If you read the manual you may realise you can instead of the root command, you can specify absolute paths. I recommend you learn only one way. All absolute or root expressions can be swapped.
eg ABSOLUTE .....kernel (hd0,0)/boot/vmlinuz root=/dev/hda15 ro becomes
kernel /boot/vmlinuz root=/dev/hda15 ro
ROOT is mentioned twice in my menu.lst file. Once to tell grub where is the /boot partition or /boot SUBFOLDER is and the second mention of root is actually a way of telling grub what partition / is on.
root (hd0,0) # first use of root
kernel /boot/vmlinuz root=/dev/hda5 ro # second use of root
So there can only be 2 types of the ROOT COMMAND
a) Preferred is to have a separate /boot partition.....so the menu may look like this and notice no mention of /boot in the stanzas
title separate boot partition
kernel /vmlinuz root=/dev/hda5 ro
title boot is a subfolder
kernel /boot/vmlinuz root=/dev/hda5 ro
MAKE FLOPPIES CAPABLE OF BOOTING LARGE KERNELS
moved to wiki link for grub here
TESTING NEW KERNELS OR MENU ITEMS
Some people like to try different kernel appends or different kernels or maybe try to load a different partition with a new linux/windows on it?
To save having to use E for edit to amend grub or C for commands grub offers a fallback menu that need no input other than setting it up.
#will allow slackware to boot if no choices made in 5 seconds and if it is buggy grub will load gentoo instead.
HOW TO BURN YOUR KERNEL TO CDR
Now a separate thread as I have started to add pix here
HOW TO INSTALL TO MBR
open a terminal
HOWTO TO INSTALL TO FLASH MEDIA or USB THUMB DRIVES
Be aware that your bios may not have an option to boot from such a device
I am indebted to LQ user Not now, John! for the ideas here.
Plan a makes a ext2 format
open a terminal
CHANGE hd2 to hd3 etc if you have 2 drives etc
CHANGE the flash media /grub/menu.lst file to reflect the hardware please
Change the /usr/shareto grub to where your backups are, eg /lib/grub
Plan B makes a MS style to be more compatible with that other thing
MENU.LST EXAMPLES FOR LINUX
Some distros talk about /etc/GRUB.conf but with luck it will be linked to the real file which is /boot/grub/menu.lst This file can be amended by any normal editor with root priveledge.
When you install GRUB it creates the menu.lst file but if it did not, use the below examples to copy and paste into a text editor and then save as /boot/grub/menu.lst
EXAMPLE of single linux with no initial ram disk image eg Slackware distro kernel older than 2.6
# file is /boot/grub/menu.lst
kernel /boot/vmlinuz root=/dev/hda3 ro
....grubspeak says /boot folder was /dev/hda1 but / folder was /dev/hda3
EXAMPLE of single linux with initial ram disk image required eg Mandrake or kernel 2.6 PLUS
# file is /boot/grub/menu.lst
kernel /vmlinuz root=/dev/hda3 ro
EXAMPLE multibooting 2 or more linuxs
# file is /boot/grub/menu.lst
kernel /vmlinuz root=/dev/hda5 ro
kernel /boot/vmlinuz root=/dev/hda13 ro
title SCSI PLAN A
kernel /vmlinuz root=/dev/sda3 ro
title SCSI PLAN B
kernel /vmlinuz root=/dev/sda3 ro sda=ide-scsi
DON'T FORGET you may need /boot preceding /vmlinuz or /initrd
Yes I its unlikely that mandrake and Scsi share the hd0,0 but they are only examples. Now as this had 4 entries the use of "default" means that unless you arrow down, at boot, to select a different entry, GRUB will boot Mandrake. Remember GRUB counts from zero. We need a timeout command to give you a chance to make the change. In the above example its 5 seconds. Once you arrow down or hit the tab key, the time count down stops. If you do nothing it will boot whatever the default number is. The word title merely acts as prompt to you as to what choices you have. Some people get really excited by eyecandy or graphics on bootup for the boot loader. You may casually notice no mention of bootsplash or splashimage commands in my files. Go to the link if you in need of eye candy. Not every distro supports eye candy.
New Kernel line alternatives UUID or label or LVM
Old style kernel line is either
kernel /boot/vmlinuzetc root=/dev/hda ro
or kernel /vmlinuzetc root=/dev/hda ro
But as pointed out to me by kilgortrout, modern distros have migrated to UUID or label.Ubuntu uses UUID. Fedora/Redhat uses label.
However, you may be able to use either if your initrd uses nash.
So to find your UUID, try these commands
So the line may become
kernel /boot/vmlinuz-etc root=UUID=5efe0bdc-7d8c-11dc-a383-65fda1769893
or kernel /vmlinuz-etc root=UUID=5efe0bdc-7d8c-11dc-a383-65fda1769893
kernel /boot/vmlinuz-etc root=LABEL=whatever
It appears you can only change the label for partition if they are ext2 or ext3?....using e2label command
LVM users...I do not use but it appears you are forced to have /boot as a separate partition and then eg
kernel /vmlinuz-etc ro root=/dev/VolGroup00/LogVol00
Thanks to homey for reminding users to have a separate /boot partition if you decide to use LVM.
Volume names can be changed with vgrename if you have conflicts.
OTHER ERRORS NOT RELATED TO DUAL BOOTING
1) Incorrect GRUB counting
2) Incorrect spaces or format of (hdX) or (hdY,Z)
There are no spaces within the hd or partition brackets.
map (hd0) (hd1).....for windows users see below but there is ONE space between bracket sets.
3) GRUB missing stage 1 or stage 1.5 or stage 2 files in /boot/grub OR one or more are corrupt and likely to have 0 byte size
4) Failure to look at /etc/fstab to see what is where, or the fstab file itself is corrupt.
5) MBR loads to a grub with a cursor means (1) GRUB is truly in MBR but you have a stage 1 etc error or the kernel line for Linux is incorrect.
6) I am not rewriting all the error codes so refer to the manual please. But Gentoo has a forum of errors here.
Please be aware that RH and gentoo etc often use /etc/grub.conf instead of the /boot/grub/menu.lst
7) motub refers to issues for those who want windows bootloader to over-write MBR
A) fdisk /mbr
is one of the ways to restore the Windows bootloader (via a floppy disk)-- but the preferred way (under Win 2000 and XP) is to boot from the XP CD, go to the Recovery Console, log in as Administrator and type
which will also restore your Windows bootloader.
B) aus9 adds--I have read you may need to zero your mbr first but heed warnings of having a real rescue system that you know how to use, as it could be nasty if you make a mistake
dd if=/dev/zero of=/dev/hda bs=512 count=1
use IF AND ONLY IF (A) fails
C) However, you will then no longer be able to boot into Linux unless you have a boot disk (or use a CD to do a rescue boot), because the Windows bootloader will not contain a Linux entry (unless you copy the boot sector from the Linux partition to the bootsector of the Windows partition and add Linux to the Windows boot menu manually).
On the whole, it's much easier to install Windows first (to the partition that Windows expects to be installed to), and then install Linux, as Linux is much more aware of how to work with Windows (if present) then Windows is aware of how to work with Linux.
(I have editted slightly to broaden the answer to more users)
8)I found in my splashimage stuff that when I grabbed gentoo files but created my menu.lst file GRUB had no problem in embedding using my file.
9) Newer Distros may complain if use syntax
/boot/vmlinuz OR /boot/initrd so change entries to
/vmlinuz or /initrd etc
10) MS to boot needs to be on a primary partition
11) If your menu has a timeout command with "timeout 0" then you can instead of editting it, press the escape key quickly numerous times to get to the menu
TROUBLESHOOTING GRUB AT BOOT MENU
I CAN NOT STRESS HOW LARGE AND GOOD THIS POST IS SO PLEASE READ IT
moved to this link
New splashimage howto with downloadable images is now here
Original info by Luis R. Rodriguez
MICROSOFT (MS) ON FIRST DRIVE and FIRST PARTIION
Don't forget the dual boot issues above.
please note that C drive must be on a primary partition....it does not need to have a bootable flag as the MAKEACTIVE command fixes all.
I tested with W98. vectordrake confirms it is the same for xp and 2000.
Until recently I used the rootnoverify with the hide command. I have decided to make it more linux like with the use of the root command but now greater use of the map command for drives and partitions.
# file is /boot/grub/menu.lst
kernel /boot/vmlinuz root=/dev/hda6 ro
We assume Windows on C drive? which is /dev/hda1 = (hd0,0) and in we are telling GRUB is .... whether DOS had it bootable or not, make it bootable, then accept a new bootloader to complete the process.
MICROSOFT (MS) on first drive and NON-FIRST partition
title MS on NON-FIRST partition
map (hd0,7) (hd0,0)
map (hd0,0) (hd0,7)
title GO TO mbr instead
Here I no longer use the rootnoverify command but align to the linux way of defining root and verify that grub knows the filesystem structure....eg fat.
The 2 map commands are to swap TRICK MS into thinking your hda8 or sda8 partition is actually first drive first partition. You need both swaps for it to work.
It does not matter if you mention hd0,7 or hd0,0 as the first command as long as they both show a true SWAP.
The title GOTO allows a sneaky way of getting to the mbr of the first drive, and then letting it boot to the C drive. Likely to be used by those who have MS on first drive and testing Linux on second drive.
MICROSOFT (MS) ON A SECOND DRIVE
You may have Linux on your first drive and decide to put MS on your second one.
I have done a separate post for my setup that may help your understanding.
It explains how to install by changing the bios.
The end of that post is this:Now you edit your /boot/grub/menu.lst file to add lines for MS.
MENU.LST EXAMPLE FOR MICROSOFT on drive 2
Don't forget the dual boot issues as above
title windows plan A
map (hd1) (hd0)
map (hd0) (hd1)
MS sits on /dev/hdc1 ( aka C drive) Grub says that is (hd1,0)
grub needs to check it finds a fat/MS file system
map says what you think is drive 1 is now drive 2 and what was drive 2 is now 1 so C drive now thinks its truly on first drive first partition. Hence MS is tricked.
makeactive says if this was not yet bootable make it so
chainloader says don't try to boot this DEAR GRUB, but let whatever that partition has a bootloader attempt to do so.
Note there is one space between the 2 map brackets.
It does not matter which drive you mention first as long as both are swapped.
title windows plan B as plan A failed more paranoid
map (hd1) (hd0)
map (hd0) (hd1)
KEEPING WINDOWS BOOTLOADER then chainloading grub on a partition
LQ user zatka found this link and updated as link changed
you have already submitted this as a linuxanswer, no need for another thread. it has been on our site for 3 months now.
heres the rough log of edits
1) Some of the links were broken
2) Give more credit to others
3) rework the notes in large kernel section to align floppy 2 note instead of floppy 1
4) add zatka's link for those who are scared to have grub in mbr on XP or 2000
5) add fallback
6) add gentoo error forum (subject to approval)
7) add backup mbr (mainly to floppy) (still no burner)
8) redo ntldr link as it changed
9) add thegreedyturtle link to fix SUSE partition table error
10) start cull as reached 25000 characters
11) reword the /boot partition to include words of SUB-FOLDER to try and make it clearer, I hope
12) samaujs found a syntax error in my map command....a bigger gap appeared to be truncated by the forum, I think. So I put a false z in there with a warning to replace it with ONE SPACE.
13) Large kernel 3 floppy tutorial made a link to the wiki document
14) Deleted simple floppy as most people, if using floppy will need to use the large kernel way.
15) Made mbr stuff a wiki link
16) add motub's windows suggestions
17) add thom for links on suse and solution
18) add Big Al for report on Mdk
19) add doug_s for link on Mdk
20) add KohlyKohl bios to LBA mode
21) make whole tut use $ symbol for commands, even if in su mode the correct symbol may be #
22) vectordrake confirms xp = 2000 = w98 for same conifgs
23) mdk 10.1 complains if I use menu.lst syntax /boot/vmlinuz so add a warning for new distros users
24) added new grub burn howto I boast its more info than grub manual
25) move the parted bug info to an archive link
26) move the burn to CDR info into main thread
27) move the trouble shooter to separate page as its now bigger
28) no longer for MS users recommend the rootnoverify command with some needing hide and unhide and stuff.
Instead I align Linux and MS users to the same root structure
then I use the map drives or map partitions to fix the hide and unhide issues and provide safer conditions HOPEFULLY for MS formatting tools etc
29) Amended ROOT command to explain search as per (28)
30) added grub to mbr for other drive as an alternative.......showing off as well
31) added timeout error for those needed help
32) added flash stuff (usb) from a post by Not now, John!
33) more choice from not now john on a device formatted as MS
34) burn grub and kernel moved to a new link off main post
35) UUID or label stuff on kernel line from kilgoretrout
36) homey has info on LVM
37) Francois du Poux for allowing me to host his stage2 grub file that has splashimage support
38) ext2/3/4 format systems now use inode 256 size which fails for legacy grub live cds
....one solution is to use a sidux live cd.
Just seen your post.
umm my last edittable post was a rough tutorial and I try to be accurate in my subject heading and originally that was correct.
No longer. Plus I reported it to try and get mods to change the subject heading to no available. I realise you guys and gals are busy with the normal stuff so I am trying to fix my past mistakes.
I will edit and link my old posts to this.
Hope that reveals my true intentions?
The ntldr link is now broken, will have to find a replacement
Great tutorial. Put it in my bookmarks :D
deleted as EDIT LOG better
(first post... uh... hooray for me?? heh!)
I just wanted to thank you very very much for the help that this thread and the others on this topic has given me. I am a complete linux newbie, and had jumped in with both feet before I was ready, and your help saved me from a whole lot of 'weeping and gnashing of teeth'. Thanx! :) :) :)
I think I would have given up on linux if not for the information that I found here. Now I have a perfectly happy dual-boot Suse/WinXP-pro system, and I am slowly but surely learning some of the workings of linux.
I need you advice
Hi I'm a student. I'm trying to write an Operating system or at thr least an Operating system interface - i mean the desktop enviroment for my final year project. I intend to use grub bootloader first, use any kernel (Linux's or preferably Win NT bootloader and kernel) and then a GUI. I intend to write the GUI from scrath and infact i have started on that. Please i need expert advice and recommendations.
Although i'm a Newbie, i cannot figure out any longer how i found myself here so i will prefer if yoou can send me a mail into my e.mail box - email@example.com
I have had to edit my howto due your question
please click on edit and delete (cull) all of your text and submit it so its blank.
Then consider doing a search or submitting a follow-up question on someone' s QUESTION thread or submit a new question.
thanks for your time.
When you do i will then cull this post as its rude but I need to be blunt.
speaking of transparent, I do not normally email anyone unless its Jeremy or something I tried to say without being rude. I will not help anyone by private email.
If its good enough for email its good enough for explicit howto instructions.
I do not provide private service. When I have time, which now a days is rare I may reply to posts.
thanks for your understanding
This is just a note to say I have severe time off restrictions at the moment so am unlikely to be updating the howto or trying to help people much in the near future.
If there is a really big issue that needs some response I am open to anyone copying and pasting my stuff and starting a new thread. Grub is bigger than my small ego.
ok I have started some updates mainly the kernel line to show extra types
of course nothing has changed for me, I do not use LVM. raid, but I may change to UUID in lieu of /dev/sdaetc
thanks a lot for guidence
thanks a lot my problem of booting fedora7 has been resolved.
|All times are GMT -5. The time now is 11:58 AM.|