Setting Up a Windows/Linux Dual Boot System
Written by CopperTop of the team.

Reference source:

Skill level: Intermediate

Location of Operating Systems
It is recommended to load the Windows o/s (operating system) to the drive that is first booted by the BIOS. Depending on how your system is set up, there are a couple possible configurations:
  1. One physical hard drive partitioned into multiple logical drives
  2. suppose your drive was partitioned into 3 logical drives – C:\, D:\ and E:\
  3. you would want to keep the Windows o/s on C:\ and maybe keep D:\ for data – this frees up E:\ for Linux
  4. the install of Linux on E:\ will automatically split this partition into three sub-partitions - /boot (boot sector), / (root), and /swap (swap space)
[*]Multiple physical hard drives
  • with Windows on the first primary master drive, you may have it partitioned into C:\ D:\ and E:\
  • installing Linux to the primary slave drive, or the secondary master drive, will result in an automatic portioning into three sub-partitions - /boot (boot sector), / (root), and /swap (swap space)
Keep track of where you install Linux to for use in a later step. For IDE drives, Linux uses the prefix hd followed by a letter for each physical drive:

a for primary master
b for primary slave
c for secondary master
d for secondary slave

This is then followed by a number representing each partition on that drive. (NB: For SCSI drives, Linux uses the sd prefix instead.)

For the examples given above, the drives are labeled by Linux as follows:
  1. One physical hard drive partitioned into multiple logical drives
    C:\ = /dev/hda1, D:\ = /dev/hda2, E:\ = /dev/hda3, /boot = /dev/hda4, / = /dev/hda5, /swap = /dev/hda6
  2. Multiple physical hard drives
    C:\ = /dev/hda1, D:\ = /dev/hda2, E:\ = /dev/hda3, /boot = /dev/hdb1, / = /dev/dhb2, /swap = /dev/hdb3

Installing Linux
Install Linux to one of the locations mentioned above and make sure you understand where /boot is located (/dev/hdxn). If you choose to manually partition Linux and skipped the /boot partition, then use the location of the root partition. No matter what distribution of Linux you decide to use, make sure you create a bootdisk. If you skip this step and something goes wrong with your boot loader set up, then you may not be able to boot into Linux without re-installing. So make sure you create a bootdisk!

During the installation, Linux will also prompt you to install a boot loader. The most common two are LILO and GRUB. If you choose to skip this step, your only option for loading Linux will be to use the bootdisk that you just created. (You did create one, didn’t you?!?) You can always boot Linux with your bootdisk and configure LILO or GRUB manually later via the lilo.conf or grub.conf files. Installing either LILO or GRUB will present you with two options:
  1. Install the boot loader to MBR
  2. this overwrites the Windows bootloader and could result in neither o/s loading if a problem is encountered
  3. should your Windows bootloader become corrupt, see Fixing the Windows Bootloadersection below
  4. otherwise, your Linux bootloader will now be the default loader for your system, giving you the choice of either Windows or Linux
[*]Install the boot loader to the Linux partition
  • requires a modification to the boot.ini file in Windows to be able to find and load the Linux /boot partition
  • see Using the Windows Bootloader section below

Using the Windows Bootloader
By default, the installation of a Windows o/s will create a Windows bootloader on the MBR (master boot record). This is the first sector that is booted by the BIOS when you start the machine. Here you will find the windows file boot.ini that tells the system where to get the files necessary for booting each o/s. This file normally resides in your C:\ directory, but may not be visible if you have “Do not show hidden files and folders” and “Hide protected operating system files (Recommended)” activated. Deactivate both of these settings through the following navigation in any explorer window:

Tools | Folder Options | View

Your boot.ini file should now be accessible.

With both Windows and Linux successfully installed, the next step is to make a copy of the Linux boot sector and copy it to Windows. To do this, boot into Linux (using your bootdisk) and switch user (su -) to root. After entering the password for root, your command prompt will change from $ to #. Mount a floppy for creating MS DOS files by issuing the following command:
mount –t msdos /dev/fd0 /mnt/floppy
With a DOS formatted floppy in the drive, issue the following command to create a 512 byte copy of the boot sector:
dd if=/dev/hdb1 of=/mnt/floppy/linux.bin bs=512 count=1
where hdb1 is the location of where you installed LILO or GRUB to.
Unmount the floppy and reboot into Windows. Copy the linux.bin file from the floppy to your C:\ directory. Edit the boot.ini file in Notepad by adding a line like the following to the end of the file:
C:\linux.bin=”My Linux Partition”
Also, make sure that the timeout option is set to a value greater then zero. If the timeout option is missing, add the following to the boot.ini file underneath the header [boot loader]:

Fixing the Windows Bootloader
For Windows9x systems, boot from a Windows boot floppy and at the a: prompt, issue the command:
fdisk /mbr
For Windows 2000/NT, boot from the install CD and enter the Recovery Console. Then issue the command:
For Windows XP, boot from the install CD and enter the Recovery Console. Then issue the command:
bootcfg /rebuild

Testing Your New Dual System
Remove all disks from the system and reboot. You should now be prompted by the Windows boot loader as to which o/s to load. Try them both and make sure they work!