LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Edit Grub when XP install won't boot (https://www.linuxquestions.org/questions/linux-newbie-8/edit-grub-when-xp-install-wont-boot-717044/)

jhinds 04-05-2009 06:54 PM

Edit Grub when XP install won't boot
 
When I installed Ubuntu it, Ubuntu, was on disk zero and Win XP on disk 1, according to the Windows drive manager. I think that Ubuntu is supposed to be on the first HD in a multiple HD system. Ubuntu set up the grub to load windows with this item in grub:

root (hd2,0)
Safedefault
Makeactive
Map (hd0) (hd2)
Map (hd2) (hd0)
Chainloader +1

When this didn't work I tried changing the drive designations around to no avail. My question is what does this syntax tell the system to do and how can I fix it to see and load my WinXP if I choose that option from Grub? My first impression on seeing this "wording" is that it is counterintuitive to map one drive to another and then reverse that.....in the very next line. So, I don't understand,,,,

Also, I set the boot order so that the drive with the Ubuntu install is the first device.

Both OS's will boot, but Grub is FUBAR!!!!!!!!!!

jhinds 04-05-2009 07:02 PM

Why won't it work to make the root read (hd1) and remove the two map lines? It doesn't, I tried....

btmiller 04-05-2009 07:43 PM

Ugh, these disk ordering issues are always a pain. I deal with this on servers a lot because various distro installers can never seem to get this right. You will probably need to go into your computer's BIOS and rearrange the BIOS drive order so that it matches up with what you expect it to be based on the IDE/SATA channel ordering. Then, get into Linux into Linux and install the GRUB MBR section onto your first hard drive (grub-install /dev/sda or grub-install /dev/hda). regardless of whether or not that is your Linux drive. Before running grub-install, make sure the GRUB root is set correctly (to (hd0,0) if your windows partitiom is the first partition of your first drive, (hd1,0) if it's the first partition of the 2nd drive, etc.). Note that the root willbe different for your Linux install. Then you should be able to get rid of the drive remapping altogether.

Basically, the root command tells GRUB what partition it needs to look for files on. The map commands try to switch hd0 and hd2. The chainloader command just tells GRUB to execute the code on that partition's boot sector (i.e. the Windows bootloader). A Linux entry looks a little different since for Linux GRUB actually loads the kernel and initrd directly without going through an intermediate.

Since you have hd0 and hd2, is it possible you have drives on two different IDE channels or and IDE and a SATA drive? I haven't played with IDE in awhile and I'm a bit rusty as to how GRUB handles that. Most of the time I've seen these problem, there's a disconnect between the BIOS drive mapping and how GRUB thinksd the drives are arranged.

Edit to add: make sure you have rescue CDs for both Windows and Linux before you go messing around with this. They will save your bacon if you mess up and overwrite a bootloader.

Junior Hacker 04-05-2009 08:38 PM

Since you say you only have two disks, leave everything including the bios settings the way they were originally. Grub counts from zero, meaning the first drive is (hd0), the second should be (hd1).
Try editing /boot/grub/menu.lst to look like this:
Code:

title Windows
  root (hd1,0)
  Safedefault
  Makeactive
  Map (hd0) (hd1)
  Map (hd1) (hd0)
  Chainloader +1

What you posted in the first post suggests grub should look at the third drive to boot Windows, of course, this won't work if Windows is on the second drive.
Quote:

I think that Ubuntu is supposed to be on the first HD in a multiple HD system.
Nope, you can install any os on any drive, normally Windows expects to be in a primary partition on the first drive, which is why you have to use the mapping to fool Windows into thinking it's on the first drive.
You can also switch the order in the bios so the Windows drive is the first boot drive, then you would have to boot into a live Ubuntu session with the Ubuntu CD to reinstall grub, the map commands would be eliminated in this case.

jhinds 04-06-2009 08:43 AM

Thanks btmiller.
All drives are SATA and I did note the drive ordering according to SATA differs considerably from the bios ordering. SATA drive 5 was BIOS drive 0, or some such. So when you say arrange order in the BIOS you mean the boot order I suppose. I already, before posting my question, redid some SATA wiring so that my Linux drive is 0 and my windows drive is 1. I thought that would be part of the fix. It just seems to me that all I need to do is edit the GRUB script that I included in my question. Here is what my boot.ini says, by the way:


[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(2)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(2)partition(1)\WINDOWS="Microsoft " /fastdetect
multi(0)disk(0)rdisk(1)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect /noexecute=optin /usepmtimer

I select the item that says "windows", not Windows XP Pro. Windows XP pro, if I select it, gives me the same error my original GRUB config displays if I select windows from there...and this is another clue I suppose, the Grub seems to maybe simply be pointing to the wrong option of the two in boot.ini.

Thanks again.

jhinds 04-06-2009 08:56 AM

And thank you too Junior Hacker.
When I saw this I thought, oh boy! the answer at last...but it doesn't work. I got a screen that said startingup, with a blinking cursor.

Hard to see why (hd1,0) won't work. As I said windows disk manager indicates Windows XP install is on drive 1 and Ubuntu shows to be on 0.

Larry Webb 04-06-2009 09:10 AM

Can you give us the results of 'fdisk -l' run from terminal as root.

jhinds 04-06-2009 09:13 AM

So, Junior Hacker, another point. You say to reset the Windows drive to boot first then boot into a Ubuntu live CD and reinstall GRUB.
How do I do this from a live CD? Seems to me that I recall trying to find a recovery function on the Ubuntu CD, but it wasn't there. If it was there how would it be accessed? Couldn't GRUB be reinstalled from within my current Ubuntu install, and if so, how?

jhinds 04-06-2009 09:30 AM

Larry Webb,

Hmmm! here is the result of fdisk -l:

john@nunya:~$ fdisk -l
Cannot open /dev/sda
Cannot open /dev/sdb
Cannot open /dev/sdc
Cannot open /dev/sdd
john@nunya:~$

jhinds 04-06-2009 09:37 AM

Larry Webb,
I am new at this so I didn't realise the fdisk command had to be preceded by sudo. New results:

john@nunya:~$ sudo fdisk -l
[sudo] password for john:

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x011b011c

Device Boot Start End Blocks Id System
/dev/sda1 * 1 29172 234324058+ 83 Linux
/dev/sda2 29173 30401 9871942+ 5 Extended
/dev/sda5 29173 30401 9871911 82 Linux swap / Solaris

Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x011b011b

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 30400 244187968+ 7 HPFS/NTFS

Disk /dev/sdc: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00e800e8

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 30400 244187968+ 7 HPFS/NTFS

Disk /dev/sdd: 1058 MB, 1058275328 bytes
2 heads, 63 sectors/track, 16404 cylinders
Units = cylinders of 126 * 512 = 64512 bytes
Disk identifier: 0x00117675

Device Boot Start End Blocks Id System
/dev/sdd1 * 1 16405 1033456 6 FAT16
john@nunya:~$

malekmustaq 04-06-2009 11:13 AM

jhinds:

Quote:============
”When I installed Ubuntu it, Ubuntu, was on disk zero and Win XP on disk 1, according to the Windows drive manager. I think that Ubuntu is supposed to be on the first HD in a multiple HD system. Ubuntu set up the grub to load windows with this item in grub:

root (hd2,0)
Safedefault
Makeactive
Map (hd0) (hd2)
Map (hd2) (hd0)
Chainloader +1”
===================

How many hard disks does your given system have? Three?
If your Ubuntu "was" on (hd0,x) and your Win XP on disk 1 then the two systems are installed in separate hard disks. Whereof, you don't need to configure a chainloader since you can make your choice at the bios sponsored boot menu pressing F11 or F12 or F9. The NTLOADER hardisk(1) should simply equate to grub's (hd1,x), and changing the root line should also need change the Map lines. {Again, why need take the trouble of mapping two hard disks if choice can be made at boot menu after the bios POSTest? Still you have to do a click at choosing through the chainload, just the same amount of calories you spend in making the choice, right? :) }

Quote: ===========
"My question is what does this syntax tell the system to do and how can I fix it to see and load my WinXP if I choose that option from Grub?"
==================

Here in Linux we need to learn the good lesson and unlearn the poor lessons we had from Windows. I was a poor windows user for ten years: there we learn simple baby tricks and think ourselves as gurus without even knowing what is happening inside the concealed exe, com, dll files. Here in Linux you can change even the kernel source and compile it if you really have the blood. There is a good tutorial on Grub, webpage or downloadable, use google.

Quote:==============
" My first impression on seeing this "wording" is that it is counterintuitive to map one drive to another and then reverse that.....in the very next line. So, I don't understand,,,,"
====================

No it is not counter-intuitive. It is just a practical syntax. Reversing it is necessary to complete the trick at the system; in Algebra: b=a or a=b and that is a spell of complete similitude. Under microsoft windows I bet you are not given the control or power to map drives and play with it pointing from one to another; that lame duck cannot even boot from logical partitions (pardon my language but there is just no other way of bringing you the message that talking about boot loaders grub offers you the best.)

Quote:=

"Both OS's will boot, but Grub is FUBAR!!!!!!!!!!"

=======

No Grub is not FUBAR. I'll show you what fubar is in booting OS. This is a real fubar:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1) \Well?

That's a real FUBAR!!! and a fubar it shall be forever until the day you can teach me how to chainload a linux or unix from that fubar line.

Again pardon me. But let me remind you that this forum is meant to help one another and NOT to proclaim a verdict that grub is fubar just because one is lazy to learn from tutorials. Read the forum rules first then in your terminal, be a root, unmount all pretensions.

Syntax is ---

# umount -a -t pride -o learn /good/manners

Hope this helps.

malekii mustaqiim

"I am a well educated arab: extremely proud and I have less respect to hypocrites. I fear no one and I have destroyed many."

Duck2006 04-06-2009 11:32 AM

Some info on grub.

http://users.bigpond.net.au/hermanzone/p15.htm

jhinds 04-06-2009 11:39 AM

malekmustaq,

You are right, and I HAVE been using bios boot menu (f11 on startup gives quick access). I am pursuing the grub issue because it is a more "elegant" way of performing the task and because I want to learn how this stuff works.

I DO want to learn this....that's why I am here.

Just because you can walk and I can crawl doesn't mean you should be so condescending. Thanks anyhow.

jhinds 04-06-2009 11:41 AM

duck2008,
Hey, thanks. I'll go look at that.

jhinds 04-06-2009 11:43 AM

posted this twice

jhinds 04-06-2009 12:28 PM

Duck2008, From reading this tutorial it would seem that one (the) reason grub didn't work is because I am using NTFS not FAT32 on the Windows drive. That's interesting.

jhinds 04-06-2009 04:44 PM

On recommendation in tutorial suggested by Duck2008 above I ran chkdsk /r on the Windows drive. It found and fixed some errors. I then booted using the grub syntax provided by Junior Hacker above and it worked. All I need to do now is make these changes permanent and the problem should be solved.

Thanks.


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