LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 08-06-2009, 04:26 PM   #1
moekad
Member
 
Registered: Feb 2009
Posts: 64

Rep: Reputation: 15
GRUB helppp


hey need help regard this:
let's say i got Windows XP on hard disk (hda1), and ubuntu on (hdb1) but while installing XP, i lost the grub loader! i enter LIVE CD and install grub back to (hdb1) and try sudo grub , root (hdb1) , setup ( where i should use this in hda or hdb)? if i want to install GRUB as MBR ?
sudo fdisk -l
# fdisk -l

Disk /dev/hda: 80.0 GB, 80026361856 bytes
240 heads, 63 sectors/track, 10337 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1764 13335808+ 7 HPFS/NTFS
/dev/hda2 1765 10337 64811880 f W95 Ext'd (LBA)
/dev/hda5 1765 10161 63481288+ 7 HPFS/NTFS
/dev/hda6 10162 10337 1330528+ 7 HPFS/NTFS

Disk /dev/hdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 4681 37600101 83 Linux
/dev/hdb2 4682 4865 1477980 5 Extended
/dev/hdb5 4682 4865 1477948+ 82 Linux swap / Solaris
#
how i can solve this ? i know if both are on same hard disk i can do in LIVE CD sudo grub then root (hd0,0) then setup (hd0) but if windows is on HDD and Ubuntu on HDD how i can let this work using GRUB >?
Thanks alot =)
 
Old 08-07-2009, 01:48 AM   #2
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Debian
Posts: 91

Rep: Reputation: 25
I think this will work: See which is the HDD that boots first, install GRUB on it and then configure it to point to hd(0,0) for WinXP or hd(1,0) for Ubuntu.
The safer way to go is using your mainboard's boot agent (if you have one) (Something like press F9 to select boot device) and select the hdd to boot from :-)
 
Old 08-07-2009, 08:02 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
There has to be a bootloader on the MBR of the disk that the BIOS lists as bootable---the BIOS tries them in order. In you example, the drive with the Windows stuff on it is shown as hda because the BIOS saw it as the first harddrive.

Boot up from live CD and run fdisk to verify which drive is which----Assuming they are in the same order as you show, then do this:

Code:
grub
root (hd1,0)
setup (hd0)
Note the syntax and the numbering. First, you always use "hd" in grub, even if Linux shows the drives as "sd".
The grub numbering starts at zero, so (hd0,0) means the first drive, first partition.
/dev/sda = hd0
/dev/sda1 = hd0,0
/dev/hdb2 = hd1,1
etc....

As already pointed out, you can put grub in the mbr of the Linux drive, leave the XP bootloader, and use the BIOS to select which drive to boot.
 
Old 08-07-2009, 11:35 AM   #4
moekad
Member
 
Registered: Feb 2009
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by pixellany View Post
There has to be a bootloader on the MBR of the disk that the BIOS lists as bootable---the BIOS tries them in order. In you example, the drive with the Windows stuff on it is shown as hda because the BIOS saw it as the first harddrive.

Boot up from live CD and run fdisk to verify which drive is which----Assuming they are in the same order as you show, then do this:

Code:
grub
root (hd1,0)
setup (hd0)
Note the syntax and the numbering. First, you always use "hd" in grub, even if Linux shows the drives as "sd".
The grub numbering starts at zero, so (hd0,0) means the first drive, first partition.
/dev/sda = hd0
/dev/sda1 = hd0,0
/dev/hdb2 = hd1,1
etc....

As already pointed out, you can put grub in the mbr of the Linux drive, leave the XP bootloader, and use the BIOS to select which drive to boot.
just last question
thanks alot for ur explanation and for Refractor last question
Assuming i have Ubuntu and XP and ubuntu install "/" as /dev/sda1 , can i install using sudo grub-install /dev/sda1 in LIVE CD ? if lost the grub ofcourse ? Regardless if there is /boot for or there is no /boot (maybe lost or removed by specific reason) ....Thanks alot =)
 
Old 08-07-2009, 02:28 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I never use "grub-install". Somewhere I read that it is better to use the GRUB shell method (as in my previous post). Doesn't "grub-install /dev/sda1" put GRUB on the partition boot sector? Normally you want GRUB on the MBR.

The "booting" link in my sig below might help----it includes a link to the GRUB manual.
 
Old 08-07-2009, 03:01 PM   #6
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
simple thing you have to under stand in grub is grub is a small systm that runs on your mbr. Master Boot record or other option for like super block of root. Mbr is where I put it.
Quote:
# Linux bootable partition config begins
title Linux on (/dev/sda1)
root (hd0,0) <---- tells grub to go to drive sda1 or hda1 and look for the folder /boot/kernel image
kernel /boot/vmlinuz root=/dev/sda1 ro vga=normal <--- this tells the kernel image to sync with the /etc/fstab file (read the file) so it can find root. this one is on /dev/sda1 on my fstab.
# Linux bootable partition config ends
so all said and done grub looks for the drive then loads the kernel then the kernel init looks for /etc/fstab to find root .
yes this does mean you can use a krnel on drive sdb1 then boot the os root file system on drive sdc1. theses are options for people that need to boot many drives server and net boot ups.


so if you boot put grub on sda and the /boot/grub/menu.1st on sdb1 your linux partition.
so your grub would be
[QUOTE]title Linux on (/dev/sdb1)
root (hd1,0)
kernel /boot/vmlinuz root=/dev/sdb1 ro vga=normal
[QUOTE] and this must match your /etc/fstab file.
Quote:
/dev/sdb1 / ext3 defaults 1 1
When you have multiple systems the best way is to have a default /boot/grub/menu.1st
and edit to load each partition /boot/grub/menu.1st like this.
Quote:
title Linux sda1
root (hd0,0) <---This tells grub to hard drive sda1 and look for
configfile /boot/grub/menu.lst <-- this then load that menu to boot with.

title Linux sdc1
root (hd2,1) <-----same as above
configfile /boot/grub/menu.lst
I have installed grub on each of theses partition but my master /boot/grub/menu.1st is on
/dev/sda3

Last edited by Drakeo; 08-07-2009 at 03:07 PM.
 
Old 08-07-2009, 06:24 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Start with "find /boot/grub/stage1". Use the answer in the root command. So if it responds: (hd1,0), then use
root (hd1,0)

The setup command should use the disk that the computer boots on. Almost always (hd0).
 
Old 08-10-2009, 05:05 AM   #8
mushroomboy
Member
 
Registered: Jan 2006
Distribution: Debian Testing ALWAYS!!!
Posts: 363

Rep: Reputation: 43
Well if your using 2 HDDs a simple and elligant solution is to unplug the hdd your not working with and do everything to the MBR. That fixed all my grub woes years ago. And I assumed your on 2 hdds because you have an hda and a hdb, which shouldn't happen with one hdd

Once your done, you can always edit grub's config to boot windows from it.

Last edited by mushroomboy; 08-10-2009 at 05:06 AM.
 
Old 08-10-2009, 08:24 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I've seen many posts where removing a disk caused problems after it was re-inserted. If the linux root partition is on the second disk, grub will be looking for it on the first disk.
 
Old 08-11-2009, 05:40 AM   #10
mushroomboy
Member
 
Registered: Jan 2006
Distribution: Debian Testing ALWAYS!!!
Posts: 363

Rep: Reputation: 43
Quote:
Originally Posted by jschiwal View Post
I've seen many posts where removing a disk caused problems after it was re-inserted. If the linux root partition is on the second disk, grub will be looking for it on the first disk.
Yes you are right, but setting up the proper disc structure before installing is good too. I have 2xSATA and an ATA drive, since sata's get sdx names it doesn't change much for me as long as I have linux on the first SATA port. You should always know where your drivers are in the bios when you do something like this, it tells you weather it should be sda sdb sdc... ect. If you have a boot problem, you can always quick edit the paramaters in grub from hd0 to hd1 or hd2 (i had a screwed up grub once where my win partition was labled wrong for the hd0). I always recomend having linux on the first hdd when you install it and install grub, and do the same for windows, this is because linux is more picky where windows will boot if you mess up the hdd order. You can always edit windows into grub, it's not so fun putting your linux back on grub when it gets messed up. =P I always install linux with all the windows hard drives unplugged and vice versa. It makes sure that the bios isn't setting a "master hdd" so that the grub/win loaders don't piss me off. I hate installing windows and having it erase my grub, nothing like a missing grub to start the day.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
helppp moekad Linux - Desktop 2 03-11-2009 07:46 AM
Helppp!error with mupen64 onimusha Linux - Games 1 09-24-2006 05:11 PM
Helppp!!!! redice Linux - Security 4 02-21-2006 02:16 PM
helppp modeprobe The Saint1 Linux - General 2 03-09-2003 12:49 PM
helppp!! martinux Linux - Networking 4 12-10-2002 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:17 AM.

Main Menu
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