LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Linux Answers > Applications / GUI / Multimedia
User Name
Password

Notices


By aus9 at 2005-01-06 04:47
DUAL BOOT TO WINDOWS USING SUSE or FEDORA or MANDRAKE USERS READ ME FIRST
moved to archive thread here
http://www.linuxquestions.org/questi...hreadid=274493

INTRODUCTION
This is document is GPL. Please do backups. Do at your risk.
Why grub??
(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.

COMMANDS are to be typed after the $ SYMBOL and assume you press enter at end of the line
eg
$ su
MEANS type "su" without the quotes and press enter

If you have KDE.....you can copy the command then in the terminal KONSOLE pull down the menu called EDIT and click on paste to insert the command.

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
http://wiki.linuxquestions.org/wiki/Using_Toms_floppy

CREDITS
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
http://packages.debian.org/cgi-bin/s...le&release=all

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
www.gnu.org/software/grub/manual/grub.html

GRUB2
Be aware that grub2 is in development and is mentioned here
http://www.gnu.org/software/grub/grub.html

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.

Command/terminal/console/shell users
Code:
su
rpm -ivh /pathway-to-file/grub-file.rpm
OR
Code:
tar jxvf /pathway/grub.tar.bz2 
or
tar zxvf /pathway/grub.tar.gz 
cd /grub-0.9.5
  ./configure && make install
Handy commands and info now become availble are: man grub
info grub
Backup stage 1 etc files MAY be in /usr/local/share/grub/ or /lib/grub/

HARDWARE COUNTING
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


HOW?

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

CYLINDER 1024
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.

COMMAND ROOT
This tutorial uses root command. eg
root (hd0,0)
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
root (hd0,0)
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.
eg
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
root (hd0,0)
kernel /vmlinuz root=/dev/hda5 ro

b)
title boot is a subfolder
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hda5 ro

MAKE FLOPPIES CAPABLE OF BOOTING LARGE KERNELS
moved to wiki link for grub here
http://wiki.linuxquestions.org/wiki/..._large_kernels

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.
eg
timeout 5
default 0
fallback 1

title slackware
kernel etc

title gentoo
kernel etc

#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
http://www.linuxquestions.org/questi...d.php?t=273164

HOW TO INSTALL TO MBR
open a terminal
Code:
su 
grub 
(prompt or cursor changes to GRUB>.)
root (hd0,0) 
setup (hd0) 
quit
Change the source of root (hd0,0) to where your /boot partition if different. Once GRUB is installed, you just edit the /boot/grub/menu.lst file to make changes. Instead of su you may have to use sudo?

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
Code:
su
mkfs.ext2 /dev/hdc
mount /dev/hdc /mnt/temp
cd /mnt/temp
mkdir grub
cd grub
(next command depending on your browser may overlap onto a second line but its typed as one command and ends  with /mnt/temp/grub)
cp /usr/share/grub/i386-pc/stage* /usr/share/grub/i386-pc/e2fs_stage1_5 /boot/grub/menu.lst /mnt/temp/grub
cd ~
umount /mnt/temp
grub   (prompt changes to grub)
root (hd2)
setup (hd2)
quit
CHANGE /dev/hdc to whatever your device is detected as
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
Code:
su
mkdosfs -F 32 /dev/hdc
mount /dev/hdc /mnt/temp
cd /mnt/temp
mkdir grub
cd grub
(next command depending on your browser may overlap onto a second line but its typed as one command and ends  with /mnt/temp/grub)
 cp /usr/share/grub/i386-pc/stage* /usr/share/grub/i386-pc/fat_stage1_5 /boot/grub/menu.lst  /mnt/temp/grub
cd ~
umount /mnt/temp
grub
root (hd2)
setup (hd2)
quit

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
title Slackware
root (hd0,0)
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
title Mandrake
root (hd0,0)
kernel /vmlinuz root=/dev/hda3 ro
initrd /initrd.img

EXAMPLE multibooting 2 or more linuxs
# file is /boot/grub/menu.lst
timeout 5
default 0

title Mandrake
root (hd0,0)
kernel /vmlinuz root=/dev/hda5 ro
initrd /initrd.img

title Slackware
root (hd0,9)
kernel /boot/vmlinuz root=/dev/hda13 ro

title SCSI PLAN A
root (hd0,0)
kernel /vmlinuz root=/dev/sda3 ro

title SCSI PLAN B
root (hd0,0)
kernel /vmlinuz root=/dev/sda3 ro sda=ide-scsi

Explain
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
Code:
blkid -s UUID
ls -l /dev/disk/by-uuid/
vol_id -u /dev/sda1
Change sda1 to whatever your real / partition is.

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

Or
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.
http://forums.gentoo.org/viewtopic.p...ror+collection
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
FIXMBR
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
http://www.linuxquestions.org/questi...postid=1413211

SPLASHIMAGE GRAPHICS
New splashimage howto with downloadable images is now here
http://www.linuxquestions.org/questi...4/#post3081720

Original info by Luis R. Rodriguez
http://ruslug.rutgers.edu/~mcgrof/grub-images/

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.

Preamble
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
timeout 5
default 0

title Slackware
root (hd0,4)
kernel /boot/vmlinuz root=/dev/hda6 ro
initrd /boot/initrd.gz

title Windows
root (hd0,0)
makeactive
chainloader +1


COMMENTS
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
root (hd0,7)
map (hd0,7) (hd0,0)
map (hd0,0) (hd0,7)
makeactive
chainloader +1

title GO TO mbr instead
rootnoverify (hd0)
chainloader 0+1

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.
http://www.linuxquestions.org/questi...hlight=windows

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
root (hd1,0)
map (hd1) (hd0)
map (hd0) (hd1)
makeactive
chainloader +1

EXPLAIN
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
rootnoverify (hd1,0)
map (hd1) (hd0)
map (hd0) (hd1)
makeactive
chainloader +1
boot


KEEPING WINDOWS BOOTLOADER then chainloading grub on a partition
LQ user zatka found this link and updated as link changed
http://www.geocities.com/epark/linux...w2k-HOWTO.html

A QUIZ
http://www.linuxquestions.org/questi...hreadid=234610

by aus9 on Wed, 2005-02-09 20:41
Mods

I had forgotten which version I had submitted for the answer section.

When you get a chance can you take a snapshot of this link as it has an expanded troubleshooter which is tooo large to have on the one posting.
http://www.linuxquestions.org/questi...hreadid=237511

Alternatively, as mods have better powers, can you make it one large post......I think I will hit the 25000 character limit wc?

So its http://www.linuxquestions.org/questi...hreadid=237511 with an embed of http://www.linuxquestions.org/questi...postid=1413211 at the section on trouble shooting?

Feel free to tell me the correct way to request an update please.

by corn_jo on Tue, 2005-03-01 13:13
hello there aus9, you sound very clued up about the GRUB boot-loader. I have a question about it, i have a computer with Red Hat 9 on it, but no boot-loader, which my computer tech loaded for me. he has now left the company, and i do not have contact with him. the red hat computer has been switched off, and the tech did not leave the 'root' password. so my question is, am i able to loader grub onto the computer, through a floppy disk before the login page, as i can not get to the desktop. or do you know of any way that i could load the system, without wiping off the red hat that i have on at the moment?

by aus9 on Wed, 2005-03-02 03:37
see my reply on this thread please
http://www.linuxquestions.org/questi...hreadid=191173


  



All times are GMT -5. The time now is 05:26 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration