LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Telling grub which partition should it boot (https://www.linuxquestions.org/questions/linux-newbie-8/telling-grub-which-partition-should-it-boot-523093/)

pxumsgdxpcvjm 01-26-2007 03:44 PM

Telling grub which partition should it boot
 
Ok. I don't know if this question belongs here, so take my apologies if such is the caso. Anyway, grub is fooling me too much and googling hasn't helped me much. I want grub to boot a certain partition, but it refuses to do it no matter what I try. This is the scenario:

I have two SATA drives and one IDE drive. Windows (2000) and Linux (Debian Etch) live in sda (1 for Windows and 2 for Debian). I boot them nicely by setting root(hd0,0) for Windows and root (hd0,1) for Debian.

This is OK. Now I have a new OS installed at my IDE's first partition (hda1 in Linux), and grub doesn't want to boot it. I tried setting root in grub to hd1,0, hd2,0,hd3,0,hd4,0 and so on. Nothing works. In the best cases (hd1 and hd2), grub complains about error 12, while with hd3 and hd4 it complains about error 21 (which AFAIK means that it couldn't find the drive).

I *can* boot hda1 if I chose that drive as the boot drive in my system's BIOS, but I'd like to integrate the new OS into grub's menu.

I *guess* that it is grub itself who gets fooled, because the bios reports hda to be the first drive (which in grub's own language is hd0), but grub calls hd0,0 the disk it is installed on.

I'm clueless :(

EDIT: FYI, grub is installed in sda's MBR

ramram29 01-26-2007 03:59 PM

If your third drive is the IDE then it should be refered to as (hd2,0). hd2 is the third drive and 0 is the first partition of that drive. You also need to make sure that the file /boot/grub/device.map contains:

(hd2) /dev/hda

Create a stanza in /boot/grub/menu.lst to boot to that drive and to that partition.

pixellany 01-26-2007 05:49 PM

You can really wind up chasing your tail with GRUB--especially if you change BIOS settings after installing and configuring GRUB.

What is your new OS? If Linux, then you can simply install GRUB from there. You can also install GRUB on that drive--IF you know what GRUB believes to be the numbering. I am very fuzzy on how this all works when you mix SATA and IDE drives.

My personal preference is to put all OSes on one drive, and use all the other dirves for data, backup, or specific directories. This avoids a lot of confusion.

saikee 01-26-2007 06:38 PM

If you want to grab Grub by its horns try read the Grub Manual.

In there you will find the command at Grub prompt
Code:

geometry (hd0)
geometry (hd1)
geometry (hd2)

can instruct Grub to tell you the partitions of all 3 of your disks. From this information you will be able to know where is you Linux, as native Linux has partition ID 0x83, Swap 0x82, NTFS 0x7 etc.

Also if your new OS uses Grub then it must have Grub's menu.lst so you can ask Grub to report to you which partition has it by
Code:

find /boot/grub/menu.lst
You can use "cat" command to display menu.lst so that you can type the commands in as displayed on the screen to boot each system up manually.

The possibilities are endless.

Still confused?

In my signature you can see a link in which I created 145 partitions and wrote the menu.lst before filling everyone of them with an OS. I can certify that Grub does not get fooled and will do exactly it is told. It boots every one of the 145 systems.

syg00 01-26-2007 08:00 PM

This "new OS" - Vista by any chance ???.

saikee 01-27-2007 03:01 AM

Grub boots a Vista no difference to a Dos, Windows, BSD or Solaris.

pxumsgdxpcvjm 01-27-2007 04:13 AM

I can finally boot it, but I still think that grub calls hd0 to the drive he lives on no matter what the bios says. This is device.map on /boot/grub:
Quote:

(hd0) /dev/hda
(hd1) /dev/sda
(hd2) /dev/sdb
But these are the commands to boot the OSes installed in /dev/sda1 and /dev/sda2:

Quote:

title Microsoft Windows 2000 Professional
root (hd0,0)
savedefault
makeactive
chainloader +1

title Debian GNU/Linux, kernel 2.6.18-3-686
root (hd0,1)
kernel /boot/vmlinuz-2.6.18-3-686 root=/dev/sda2 ro
initrd /boot/initrd.img-2.6.18-3-686
savedefault
Quite strange that in device.map hd0 is /dev/hda while in boot time hd0 becomes /dev/sda. Should I edit device.map accordingly?

Anyway, the new OS I wanted to boot is MS-DOS 6.22. In the grub world, it lives in hd1. DOS' boot code gets installed on hda's MBR, so this is the grub stuff to boot it:

Quote:

title MS-DOS 6.22
root (hd1)
chainloader +1
Pointing grub to hd1,0 gave me error and I can figure why it did so, but I don't understand why grub doesn't honour his own device.map. Finally, 'savedefault' and 'makeactive' resulted in error n. 12. Without them, DOS boots OK.

Anyway, thank you all for the tips. You are so nicely helpful people :)

PS: I'm no particularly anti-MS and I love Windows 2000 (which IMO is an OK desktop OS), but I'll NEVER install Vista here. They really screw it up with it.

saikee 01-27-2007 04:48 AM

Here is my "speculation" of what happened.

The device.map can be accurate if

(1) you have since changed the disk order either knowingly or unknowingly. The plugging and unplugging of hard disks can cause the Bios to alter the disk order too.

(2) Initially your hda did not have a bootable system and the Bios proceeded to boot the OSs in the second disk sda.

The way Dos boots from "root (hd1)" means you use Grub to boot up the MBR of hd1 and it is this MBR that boots up Dos and not GRub. This is totally acceptable, say the MS's MBR has been installed in hda and it boots whatever primary partition in hda with the booting flag switched on. If Grub doesn't boot by "root (hd1,0)" then perhaps your Dos is in a partition other than 1st partition 0. This is quite possible as I could not image when you installed Win2k and Suse booting from sda your hda was a raw disk at that time without any partition inside but occupying the first bootable disk status.

The makeactive command cannot be applied to the whole disk hd1. I am not entirely sure if savedefault can be accepted for such a booting choice either.

You can show us the output of "fdisk -l" if you want a deeper investigation.

pxumsgdxpcvjm 01-29-2007 01:54 PM

Quote:

Originally Posted by saikee
If Grub doesn't boot by "root (hd1,0)" then perhaps your Dos is in a partition other than 1st partition 0.

Yep. That was it. I had problems booting my brand new (LOL) DOS because it is not installed on hda1 but on hda3. This comes from dmesg:
Code:

hda: 234441648 sectors (120034 MB) w/2048KiB Cache, CHS=16383/255/63, UDMA(100)
hda: cache flushes supported
hda: hda1 < hda5 hda6 hda7 > hda3

and this is the fdisk -l output for hda:
Code:

Disposit. Inicio    Comienzo      Fin      Bloques  Id  Sistema
/dev/hda1              14      14593  117113850    f  W95 Ext'd (LBA)
/dev/hda3  *          1          13      104391    b  W95 FAT32
/dev/hda5              14        5235    41945683+  7  HPFS/NTFS
/dev/hda6            5236      10457    41945683+  7  HPFS/NTFS
/dev/hda7          10458      14593    33222388+  7  HPFS/NTFS

So DOS is installed on hda3, which is the active partition on the disk, and hda1 is an extended partition containing some logical partitions. Quite fun, but this explains my DOS boot drama.

Quote:

Originally Posted by saikee
(1) you have since changed the disk order either knowingly or unknowingly. The plugging and unplugging of hard disks can cause the Bios to alter the disk order too.

I didn't do this. I'm sure that Grub doesn't work as it should. Maybe it is Debian who is in fault. I don't know.

I say this because of this is an almost vanilla Debian. And I remember that when I first rebooted after installing it (just basic system, I apt-getted later for X and KDE), the Debian installer wrote 'root=/dev/hda2' instead of 'root=/dev/sda2' in the Linux entry and 'root(hd1,0)' instead of 'root(hd0,0)' for the Windows 2000 entry. The same happens if I now do a 'grub-install'. I knew how to edit the boot commands and also knew where I installed Debian and Windows, so that saved my butt and made it no problem at all. I guess that this can be fixed by editing device.map properly, but it is Grub (or Debian) who fools itself.

Am I the only one to experience this?

Regards!

syg00 01-29-2007 04:14 PM

Grub is rarely (never ???) at fault in these things.
Poorply designed and/or implemented (distro) installer. Anaconda is another that doesn't handle multiple OS's on different disks very well.
I prefer to do my own grub builds.

saikee 01-29-2007 04:58 PM

From my experience if a distro has bugs the installer possibly has the most of it.

Grub seldom gets wrong unless you boot it with an older Grub, say 0.91 on a newer Linux that has been packaged with Grub 0.97.


All times are GMT -5. The time now is 07:00 PM.