-   Linux - Newbie (
-   -   ripping hair out!- grub dismay (

tnewman1972 05-26-2008 07:22 AM

ripping hair out!- grub dismay
hi all,

ive attempted to install various linux distros over the past few months and although i can experience it with vmware or other virtualisation software i cannot for the life of me work out what is going on with respect to grub and drives.

i hope someone can assist me to unlock this roadblock for me.

this is the scenario.

i have windows xp, or vista or whatever installed on disk 0.

i have 2 other disks, 1 and 2.

this is the info i get from the computer management console from windows.

disk 0 is standard disk drive, location 0 (0)
disk 1 is standard disk drive, location 0 (primary ATA channel)
disk 2 is standard disk drive, location 0 (secondary ATA channel)

when i try to install linux, the orders are completely different to this.

i havent got an exact screen to refer to but it refers to scsi3 as my disk 1, scsi2 as my disk 2 and scsi5 as my disk 0 (or something like that).

i have no partitions on any disks.

after all the pain i am thinking that perhaps my bios and physical connections on my motherboard dont line up- or that my limited understadning of linux is that it treats sata and ide drives as different and as such orders them differently to what im used to.

perhaps if i can connect them physically so there's continuity between the OS's thatll help (?)

anyways, after i select "guided, use entire disk", i check the advanced settings and see that the bootloader is to be installed on hd0.

this , to me, is where disk 0 is- which is where my mbr is...right?- well it must be wrong as it never works...grub error everytime.

can someone please look this over and work through it with me?

ive searched the net trying to find a decent, unambiguous explanation and have yet to find one.

looking forward to any help at all.



Agrouf 05-26-2008 07:56 AM

If you have a liveCD, you can boot and launch grub. Then, you can use the root and find command.
Anyway, you say disk 1 is on primary ATA channel and disk 2 is on secondary ATA channel, so where is disk 0?
Also what is the linux device for those disks? When you say scsi5, do you mean /dev/sda5 or something like that? I expect grub hd0,0 to be /dev/sda1 in linux, or /dev/hda1. Please verify which devices linux uses and where grub is installed.
Then verify /boot/grub/
If grub is indeed installed in hd0,0, open grub and type this:
grub> root (hd0,0)
grub> setup (hd0)
(or something else depending on where grub is installed).

stefan_nicolau 05-26-2008 07:58 AM

A few questions:
a) what types of disks do you have (ide, sata, scsi, usb)
b) what device node does each disk get
c) are all disks on the same controller? If not, race conditions at boot might mean that you will never get the same device mappings.

please be a bit more precise i.e. "i have windows xp, or vista or whatever installed on disk 0" and "i have no partitions on any disks" does not make sense.

Also, why do you want the disks to be detected in the same order in Windows and Linux? This might be very hard to achieve and does not seem useful.

EDIT: Agrouf beat me to replying

pinniped 05-26-2008 08:28 AM

Aha! Another WinDuhs victim!

I'll try to explain it, but there's an awful lot of history that I'll do my best to skip.

1. When the computer is switched on, the BIOS does all sorts of magical things. One of these things is Disk Enumeration - it will call the detected disks '0x80', '0x81', and so on. (Don't ask why - that's a history question I don't want to answer.)

2. To overcome a limitation of all WinDuhs bootloaders (including ntldr), the BIOS is kind enough to allow the user to change the enumeration.

3. The bootloader doesn't have to follow what the BIOS indicates. At some point in history, for some reason not entirely known to me, people decided that there is some advantage to ignoring the BIOS.

4. Microsoft went one step further and decided to enumerate disks by some method that I won't even attempt to decipher; in the past this has resulted in MS software swapping my disk(0) to disk(1) and thus rendering my WinDuhs machine unbootable after a shutdown. There are good docs that explain the rather bizarre scheme that you see in the boot.ini file, but I could find nothing explaining the mysterious swap that I experienced.

5. To chain-load WinDuhs, both Lilo and Grub can re-enumerate the HDs before they invoke ntldr. (in lilo for example, you use 'disk= bios=' pairs: disk=/dev/hda2 bios=0x80)

So going back to your question, the flexibility of a modern BIOS in [2] may cause different enumerations if you change options such as 'boot order'. Aside from that, enumeration will most likely be different if you simply moved your HD around (different IDE channel, master/slave). In fact, you can sometimes counteract the screwup due to [2] by moving the HD around. (Not recommended unless you're extremely desperate - it's not the smart way to work.)

IF you moved your HD with WinDuhs (which many people do), the trick is to first get Linux booting, then fix up the chainloader part of the bootloader config to reenumerate the disks so that WinDuhs boots again.

Now how do you know which disk etc has what while you're installing? If you can bring up a command console from within the installer, you can use 'fdisk':
fdisk -l /dev/hda
(or sda or whatever you've got)
That should show you the partition information and you should be able to figure out most things from there.

One word of caution: Grub and Lilo don't care if Stage1 of the bootloader starts from MBR or a partition and they really don't care what disk they're on (why should they), but all WinDuhs bootloaders have a special feature - they MUST be on that 'first' disk as defined in 'boot.ini' - whatever that disk happens to be. Obviously writing bootloaders is not Microsoft's forte (nor is writing operating systems).

PS: Bootloader Stage1? Yes, with IBM PC HD partitioning (ancient history!) there is the Master Boot Record (MBR) which has some information about the partitioning; at least enough information to point to the 4 'primary partitions'. One of those primary partitions can be further divided (giving you the 'extended' partitions). Each partition has yet more information about the information on it. Now - the MBR has about 512 bytes dedicated to holding this partition information AND allowing a small space for the bootloader. Similarly, all partitions have a 512 byte block with information about that partition and space for a bootloader. Anyway, you can't do much with 512 bytes, much less the smaller amount set aside for the bootloader, so that tiny amount of code that can be crammed into the MBR or partition record simply asks the BIOS to start loading a program from another part of the disk - the Second Stage bootloader. This second stage doesn't have strict size limits like the first stage and you can do all sorts of fun and useful things. You can keep chaining bootloader bits in this fashion but really 2 stages is sufficient for most things. Grub has a third stage called 'Stage1.5' which is occasionally useful for things.

Emerson 05-26-2008 08:48 AM

Amen. :) For sake of clarity and keeping things under control I'd suggest you never change the boot order in the BIOS.

tnewman1972 05-26-2008 08:12 PM

wow guys..great set of replies im sure- if i wasnt a linux noob....but alas i alot of the above is very confusing to me.

actually when i ripped my hair out some months ago trying to install linux on a separate drive to windows i did swap the drives around in the not sure if i even did it via the physical sata connectors on my motherboard as well...i seem to recall i may have.

i have 1 IDE connector and 2 sata on my motherboard. the mobo is a gigabyte m57sli4 and has 1 ide and 6 sata connectors.
windows is installed on the ide.

i guess what strikes me is that its this difficult to install linux. I wouldve thought that there would have been an option to select where to install the bootloader- or even have a dialogue to ask what it wants the user to do- i.e. do you want to dual boot?- etc..

so i get error 17... and the bootloader installs to hd0. How do i find out exactly what hd0 is and where my current windows is installed?

(the installer shows my windows drive at sdc).


Cheers, im sure ill get there with your help.


tnewman1972 05-26-2008 08:14 PM


Originally Posted by stefan_nicolau (Post 3164872)
A few questions:
a) what types of disks do you have (ide, sata, scsi, usb)
ide, sata
b) what device node does each disk get
what the?!
c) are all disks on the same controller? If not, race conditions at boot might mean that you will never get the same device mappings.
what the?!

please be a bit more precise i.e. "i have windows xp, or vista or whatever installed on disk 0" and "i have no partitions on any disks" does not make sense.
no partitions other than the basic OS. I have xp pro on disk 0.

Also, why do you want the disks to be detected in the same order in Windows and Linux? This might be very hard to achieve and does not seem useful.
because i know what order they are in windows.

EDIT: Agrouf beat me to replying

answers above.

masonm 05-26-2008 08:25 PM

I suspect that the problem lies in the grub menu.lst and whatever root drive is listed there isn't correct so grub can't find the kernel image to load.

You'll need to post the specific menu.lst installed in order to figure out what's going on. The fstab file would also be helpful.

yancek 05-26-2008 08:38 PM

Every version of Linux I have installed has had an option of where to install the bootloader. It's usually the last choice at install. The default is to the mbr. I don't believe any version of windows gives this option but I may be wrong.

The installer shows your windows drive as sdc which means the third hard drive. There should be a number for the partition after the 'sdc',i.e 1,2,3,etc.

If you don't know what the boot order in the BIOS is you need to check that or you will be installing on a different drive than you think you are. The same goes for the order of cables from your hardrives to your motherboard.

hd0 is your first hardrive. A simple google of 'grub' will get you all kinds of information, particularly on naming conventions. hd0 - first drive, hd1, second drive, etc. Linux numbers hardrives as hda (sda), hdb (sdb)etc. If you have 'sda1' you are looking at the first hard drive, first partition.

If you have a Linux live CD (all kinds of sites with free downloads) you can run the fdisk -l (lower case L) command to find out where your windows partition is. This is probably the first thing you need to do so that you have some idea of where your partitions are and what's on them in the eyes of your computer.

If you think Linux is hard to install, try installing windows onto a hardrive with another OS already on it which you want to keep.

stefan_nicolau 05-26-2008 10:42 PM

Windows seems to be on sdc1. The other disks are sda and sdb, and you should be able to install linux on either one of them. To confirm, can you post the output of 'fdisk -l' (run as root). The bootloader should go on the disk that is set to boot in the BIOS, i.e. probably sdc. Grub is likely to call this hd2 (see /boot/grub/ You can also install GRUB onto hd0 (sda) and then change the boot device in the BIOS (though other posters warned against this).

tnewman1972 05-26-2008 11:46 PM

thanks so much guys...installing to sdc makes the most i just over write the (hd0) to (sdc)? when i get the option during install?

also, can i run fdisk -l from a virtual machine? (i figure not) good if i can though.

the weird thing- and most confusing for me is that for all intents and purposes hd0 IS my first HDD and it is the one that corresponds to my windows installation- via bios and computer management...well thats what i see...ill check and get back.


tnewman1972 05-26-2008 11:48 PM

oh i fogot- can i use gparted to do this stuff too?- ive used that in the past- that was what enabled me to get linux running- once..

Agrouf 05-27-2008 01:30 AM

No, it won't work from virtual machine, because the virtual guest OS doesn't know about real hardrives. The virtual machine create fake hardrives that the virtual OS sees.
You can do this from a liveCD. Probably your installation CD is a liveCD. You didn't tell us what distro you are using. Anyway there are literally thousands of liveCDs to download from the internet. Your installation disk should have an option to at least run bash to enter commands.

tnewman1972 05-27-2008 03:30 AM

ok heres a copy of the screen returned after running fdisk -l

actually to me it looks like hda1 is correct...being ntfs and 160gb.

sda is where i attempted to install its auto partitioned.

sdb is my third hdd- 160gb ntfs.
sdc is an external usb hdd.

so should i be changing the boot install location to hda1?- it defaults to hda0..

Device Boot Start End Blocks Id System
/dev/hda1 * 1 20672 156280288+ 7 HPFS/NTFS

Disk /dev/sda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 23569 189317961 83 Linux
/dev/sda2 23570 24321 6040440 5 Extended
/dev/sda5 23570 24321 6040408+ 82 Linux swap / Solaris

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 19457 156288321 7 HPFS/NTFS

Disk /dev/sdc: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 9729 78148161 7 HPFS/NTFS

stefan_nicolau 05-27-2008 10:58 AM

Installing to hda should have been fine, if that's the device set to boot in the bios. What happens when you try to boot the computer (having installed grub to hda)? You can also try installing grub to the mbr of every disk in your computer (overkill, but I did it on my computer because I can't tell the difference between multiple identical disks in the bios).

All times are GMT -5. The time now is 09:26 PM.