[How To:] Fix the problem when XP doesn’t boot from GRUB

Intro : First, GRUB was erased. After fixing it, XP did not boot from GRUB owing to ‘ERROR 12’. Lastly, How I could fix both, rather discovered work-around for some part.

Recently I faced the first battle arising from the conflict between Windows and Linux. Thanks to Linux, I won it ๐Ÿ™‚ .Let me give you a brief history of the problem.

I had to format my friend’s hard disk for some reason and connected it to my comp. Here, the sane me should have relied upon Ubuntu Live CD and formatted the whole thing. But the insane me chose to rely upon Windows. So, I used Partition Magic ver 7.0 and tried to do the job, but failed miserably. After a few more futile attempts, the Insane me decided to rely upon Windows again. I used the WinXP Pro installer CD and wished to format the slave drive through DOS. Voila! It worked. My friend was too happy and left my place cheerfully!

Now, I switched ON my PC after sometime and to my horror, didn’t find the GRUB. (GRUB – GRand Unified Bootloader; somewhat similar in concept to the OS-selection menu in Windows) WTF!!! What did Windows do to my GRUB? Being a newbie to Ubuntu, I was clueless. I tried hopelessly to somehow fix it up by using the live CD. FUCK! No success. Then, I browsed through the web from the Live CD itself and found this link which was very helpful. (Plz go through the link to understand what is written further)

Assuming that u’ve gone through the link I’ve given above, I’ll use a few terms without any explanation. I created the GRUB diskette as described in the above link. After leaving the diskette in the floppy drive, I rebooted the PC.

Run the system BIOS. Make sure you’ve specified the boot device priority in this order : 1st – Floppy drive, 2nd/3rd – CD Drive/Hard disk. Save changes and exit. Now, the PC reboots again and something like this appears.

[ Minimal BASH-like line editing is supported.ย ย  For
theย ย  firstย ย  word,ย  TABย  listsย  possibleย  command
completions.ย  Anywhere else TAB lists the possible
completions of a device/filename. ]

grub>

First, I specified the root drive where GRUB has to be installed, by this command

grub> root (hd0,4)

hd0 – My 1st hard disk.
4 – the partition number on the first hard disk where GRUB is to be installed.
Generally speaking, the ‘n’th partition of the ‘m’the hard disk is written as (hd[m-1],[n-1]).

Next, I’d to setup the GRUB, and this command did the job.

grub> setup (hd0)

This command sets up the GRUB on the root drive specified. Simple enough right? ๐Ÿ˜‰ Now, remove the floppy diskette, change the 1st boot device priority to hard disk and reboot. A round of applause ladies and gentlemen, a novice just meddled successfully with GRUB, MBR (Master Boot Register) and a few alien things, of whose importance I know little about! ๐Ÿ˜€

But my sigh of relief was shortened when booting into XP was not possible ๐Ÿ˜ฆ . Ubuntu could not mount the XP drive even at startup and I was left clueless again. Fuck! ๐Ÿ˜ฆ I thought about it for a while and tried out something which would turn out successful. Here is what I did.

  • Make the 1st boot device as CD-ROM by following the procedure mentioned earlier.
  • Insert XP installation Disc into the tray.
  • Let it do all the pre-install-setup-bullshit.
  • When it asks if you wish to install XP or repair using Recovery console, press ‘R’ which means the latter option.
  • It scans your hard disk for available XP installation and asks you to select the one you choose to repair.
  • Enter the Number specified against the Installation you wish to repair and press ‘Enter/Return’ key.
  • Type this command and press ‘Enter’ย  key.

C:\WINDOWS>CHKDSK C:

  • This thing checks the apparently inconsistent FAT/FAT32/NTFS/NTFS-3g disk drive for volume errors and fixes them.
  • Now boot into Ubuntu or any other distro and go to the drive where you’ve an installation of XP.
  • Copy the files “AUTOEXEC.BAT”, “boot.ini”, “CONFIG.SYS”, “IO.SYS”, and “MSDOS.SYS” into some other drive. Congrats! You’ve just made an alternate “boot sector” for WinXP ๐Ÿ˜€ . Please note the partition number of the destination drive.
  • Now, to edit the GRUB menu : open the all powerful ‘Terminal’ and type the following command

sudo gedit /boot/grub/menu.lst

  • Provide your password. The window opening now is the ‘menu.lst’ file which determines which OS boots from which partition. scroll down to last to find something like this :

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
titleย ย ย  ย ย ย  Other operating systems:
root

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sda1
titleย ย ย  ย ย ย  MS WinXP Pro
rootย ย ย  ย ย ย  (hd0,1)
savedefault
makeactive
chainloaderย ย ย  +1

  • I’ve ‘bold’ed the parameter to be changed in the above sequence.
  • Primarily, my XP partition was (hd0,0). But, in the above visual, it shows (hd0,1). That means, I’ve changed the drive, which XP seacrhes for the boot sector to exist.
  • In your case, If the files you’ve to move are in the 1st partition of your first hard disk then it should be as (hd0,0) in the GRUB menu file, initially. If you are copying the files to the 2nd partition of the first hard disk, then change the ‘bold’ part to (hd0,1) as in my case. As said earlier, the ‘n’th partition of the ‘m’the hard disk is written as (hd[m-1],[n-1]). Save the file and close.
  • That said, make the change only in the ‘bold’ed part and NOT anywhere else, because, I CANNOT help you with the problems arising out from that.
  • Reboot your PC and you should be able to boot int XP. (Atleast, I could do it in my case, and so, since there is nothing much to meddle with the hardware, your problem should be solved too.)

Important part : Disclaimer : I’m a novice and did many things (esp the latter half) according to my instinct/intuition and was not guided by any tutorial either on the WEB or on paper. So, it is up to you to believe in me and perform all these, the proof of whose working is the successful re-birth of my PC without any damage, and through which I’ve written this post ๐Ÿ˜› .

I do not know the persom whose link I’ve provided here. Whoever you are, thank you very much, man. You revived my hopes ๐Ÿ™‚ .

If anyone else faced the same problem and solved it in a different way, Please let me know. If any pro’s or Ubuntu/Linux Gurus find this stupid, please educate me further.

And so ended my first adventure in Ubuntu ๐Ÿ™‚ . Hope I see much more and learn much much more! ๐Ÿ˜€ Thank you for being here.

Advertisements

23 thoughts on “[How To:] Fix the problem when XP doesn’t boot from GRUB

  1. The HOW TO is nice. But it does lack description. The first thing being what exactly was the problem you encountered. Because Error 12 turns up in many hard disk related problems. As you don’t know EXACTLY what happened with your installations, the how to applies only to your PC temporarily. Even if someone has a different problem and searches for these keywords to help him out, he might actually be screwing his PC even further. So you need to be PERFECTLY sure what was the problem, why the error was shown and what exactly you did in order to write a proper HOW TO. I hope you don’t mind the criticism. That too in the first comment itself.

  2. Anniyan
    I think I understand your concern. But, at the end of the day, my PC was fixed and the method isn’t machine-dependent or vague. so, i suppose it’ll pass off your criticism, although with a li’l rough ride ๐Ÿ˜€

    Reema
    Thnx a lot! ๐Ÿ™‚ I hope it helps someone I’ll see DI asap. ๐Ÿ™‚

    Sakhi
    Neva mind! next post should interest you. be here on monday at 9 am. ๐Ÿ™‚ (WP time ๐Ÿ˜› )

  3. there is no ntfs-3g filesystem, its just a driver to access ntfs filesystem from linux.

    You could have restored grub using Ubuntu live cd or knoppix (its the best linux live cd). Alas…I dont have floppy drive connected to my system.

  4. Meghana
    Choose what is right! but be careful while installing XP. Windows over writes the MBR-Master Boot Register and hence disables GRUB. U may have to restore GRUB like I did. ๐Ÿ˜›

    T
    Thnx a lot for the correction dude ๐Ÿ™‚ I dunno anything about Knoppix yet. ‘l see wht it is asap.
    “A geek in the making!” – At the end of the day, i would be more happy if i won over Windows. It can drive me crazy sometimes ๐Ÿ˜€ ๐Ÿ˜†

  5. Pingback: Welcome Reader! « Su

  6. Amit
    thnx a lot for the correction. ๐Ÿ™‚ i guess it happens with newbies. Could u give me a link to reach Hiren’s Bot Disk, just in case i dont get good result by googling it up. ๐Ÿ™‚

  7. Hi Su,
    I Arif a Software Engg from Bangalore, I have developed a tinty utility for Windows OS, which help you perform your day to day task quickly and makes them easier.

    I am requesting you to use it for sometime, do blog about it, only after you like it.

    Thanking in advance for your consideration.
    -Arif

    Sorry about posting it here, but i could not find your personnel email Id to send this email.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s