October 30, 2004

Dual Booting Windows XP/2000 and Red Hat Fedora Core 2

There are two ways in which you can dual boot between windowsXP/2000 and Linux.
  1. Install the boot loader in the Master Boot Record (MBR)
  2. Install the bootloader on the linux partition.
The first method is the easier of the two. But if by any chance, you descide to Hibernate your computer while in WindowsXP for example, then your MBR is overwritten by windowsXP and you will be unable to boot into linux using your bootloader.
Here I will explain how to overcome this setback by using the second method. That is installing the bootloader (LILO or Grub) on the linux partition . Here I am explaining the steps with respect to RedHat Fedora Core 2 distribution. But the steps are equally valid for any linux distribution.
The procedure is as follows:
  • Install WindowsXP/2000 first.
  • Now install Fedora core 2. I installed it in /dev/hda3 ; which was my linux ext3 partition.
  • While installing, enforce LBA32. This is necessary only if you intend to install the bootloader in a partition above 32GB. In my case (I have only 12 GB total) it was not necessary.
  • At the section where the installer asks whether you want to install a boot loader; select yes (Fedora comes with Grub as default boot loader) and in the advanced settings, select your linux partition as the place to install the bootloader. In my case it was /dev/hda3. Nowcomplete the Fedora core 2 install.
  • Reboot the computer and load again from the first CD in your Fedora Core 2 distribution.
  • At the boot prompt, type:
    boot: linux rescue
    ... And boot into rescue mode. Fedora will automatically try to detect your linux partition ;boot you into single user mode and mount your linux partition in the /mnt/sysimage directory.
  • Here when you get the root prompt, issue the following commands:
    # chroot  /mnt/sysimage
    # dd if=/dev/hda3 of=linux.bin bs=512 count=1
  • Now insert a floppy and copy the linux.bin file into it as follows:
    # mcopy linux.bin a:
  • Type exit 2 times - which will reboot your machine. Now remove the FC2 CD and boot into windows XP/2000.
  • Get to the command prompt and copy the linux.bin file into the C:\ drive.
    A:\> copy linux.bin  C:\
  • Finally add the following line to the boot.ini file residing in the C:\ drive.
    C:\linux.bin=" Red Hat Fedora Core 2"
  • Reboot machine and choose "Red Hat Fedora Core 2" from boot.ini menu, which will cause NTLDR to load first 512 kb from Fedora Core 2 boot partition.
  • Select from grub menu the desired kernel and press Enter.
Now even if you hibernate while in Windows XP, your bootloader will not be overwritten and you will be able to boot successfully into Linux.

6 comments:

Michael said...

Hi, Ravi

I wonder what's the purpose of copying the linux.bin file into the C:\ drive. Can we possibly skip this step, when we install the Grub into Linux partition? ( I do not have any floppy with me, but I still like to Hibernate my windows sometime.)

Any suggestions?
Thanks

Michael said...

Another question related to partition is, "what is a reasonable partition scheme and the sizes for each directory, such as /root, /dev, /usr...?"

It seems to me that the automatic partition by linux is not the optimal for efficient storage usage, so manual partition is perfered. However, I can not find a good guide on the recommmended directories and their sizes (Mb).

Ravi said...

Michael,
You copy that file (linux.bin) to C:\ drive so that it is accessible by the windows boot loader as in boot.ini file. Which means, when you boot up your machine, you will get the windows bootloader menu containing the choice of booting into windows or linux - instead of the grub boot menu.
It is not compulsary that this file should be in C drive itself. It could also be in D:\ drive or even on a floppy in which case, you have to change the path in boot.ini to reflect that.
--
Answer to your second comment
--
That entirely depends on your requirement. For a home user, you need have only 3 partitions as follows:
/boot - 100 MB
swap - twice your RAM
/ - rest of the space

But if you are running a mail server or a webserver, then it is desirable to create more partitions for other directories like
/boot - 100 MB
swap - twice the RAM
/var - 2 GB (contains the log files , fills up fast)
/ - 10 GB (would be enough if you don't frequently install applications )
/home - the rest

Michael said...

Ravi,

Recently, I am trying to install Ubuntu using the same trick you mentioned here for dual boot, but it doesn't work. My guess is that we need to use something other than:

dd if=/dev/hda3 of=linux.bin bs=512 count=1

for XP boot loader to boot into Ubuntu? Thanks a lot.

Michael said...

I found the answer here:
http://ubuntuforums.org/archive/index.php/t-80508.html

bootpart is able to copy the boot sector without problem, and it's easier than the one you need to boot into rescue mode. But I still don't know why dd fail in the case of Ubuntu?

Anonymous said...

Ravi,
U can skip the copying process of linux.bin to Floppy Drive if u make a partition /anyName in vfat to be used by both Windows & Linux. Then u can copy the file linux.bin to the specified vfat partition by issuing command

$ mcopy linux.bin /anyName.

After that boot into Windows and copy the file linux.bin from the partition to C: and then add the lines

C:\linux.bin="Red Hat Core 3"

U can contact me at the_22boy@nerdshack.com

Get Posts via email