Linux-Windows XP Dual-Boot

Introduction

The following guidance might be useful in helping to configure a system to be dual-bootable into either Linux or Windows XP. It outlines what I did in order to get a laptop PC dual-booting into either Linux (CentOS, a Red Hat/Fedora Core Linux variant) or Windows XP (users of the PC other than myself have no concept of there being life outside Windows!). So while it describes what worked for me, and you may find it useful, it is by no means definitive and as with any low-level operations on hard-disk drives you are advised to have confirmed good backups before you start fiddling! Any actions you take on your hardware are strictly your own responsibility.


General Setup

Preparation

The original HDD in an Acer laptop had died and was being replaced by a newer, larger HDD. The laptop has no floppy drive so booting from a floppy disk was/is not an option. The laptop is bootable from CD-ROM.

I wanted to add Windows to a laptop PC that already had Linux installed. However during this process I had numerous difficulties despite following the various advice provided in the links in the table at the bottom of this page and I had to experiment with having first one OS installed and trying to install the second and then vice-versa. After much tinkering about, re-partioning, re-installing, re-booting, etc., etc., etc., I finally got to a working system with both OSs bootable.


Disk Partitioning


Summary

The laptop has a single, large (160GByte) Seagate hard disk drive to be used to house both OSs; it does not really matter which is installed on the first partition.

The following experimentation was tried:

In order to re-partition the hard drive to the required Linux/Windows split this was manually using the latest version of the GNOME Partition Editor: thus a copy of gparted-livecd-0.3.4-10.iso was acquired from: http://sourceforge.net/project/showfiles.php?group_id=115843&package_id=173828 and burned to CD-ROM.


Details

Partioned as follows:

Reduced the /dev/hda1 Windows partition by ca. 20Gb, resulting in:

Re-boot off CentOS CD. Use Disk Druid to configured the unallocated space as follows:

Other configuration options set:

The remainder pf the CentOS installation was completed and the system re-booted. The grub menu appears and offers the two options as anticipated, and both boot as required.


Grub Bootloader

There is a choice of two bootloaders under Linux: either Grub or LILO. See http://www.dedoimedo.com/computers/grub.html for more detail. I opted to use Grub, as most the documentation and linksI read seemed to indicate it was the better choice.

Initally during this process I wanted to install Linux on the first partition, Windows on the second and then have a grub.conf file similar to that shown below:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hda10
#          initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
password --md5 whatever-whatever-whatever
title CentOS-42 i386 (2.6.9-22.EL)
	root (hd0,0)
	kernel /vmlinuz-2.6.9-22.EL ro root=LABEL=/ rhgb quiet
	initrd /initrd-2.6.9-22.EL.img

title WindowsXP Home Edition
	map (hd0,0) (hd0,10)
	map (hd0,10) (hd0,0)
	rootnoverify (hd0,10)
	chainloader +1

But as described earlier the final configuration had to have Windows installed on the first partition and Linux on the second, so this grub.conf file is no longer applicable.


Final Configuration Details

At the conclusion of the installation process the final grub.conf file (after a minor update to adjust the title line to more precise output) is as shown below:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,1)
#          kernel /vmlinuz-version ro root=/dev/hda10
#          initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=6
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
password --md5 whatever-whatever-whatever
title CentOS-42 i386 (2.6.9-22.EL)
	root (hd0,1)
	kernel /vmlinuz-2.6.9-22.EL ro root=LABEL=/ rhgb quiet
	initrd /initrd-2.6.9-22.EL.img
title Windows XP HE SP2
	rootnoverify (hd0,0)
	chainloader +1

Windows was set as the default OS to be booted, as most users of the laptop will use Windows.

The output from a few system commands, below, show the final configuration of the hard disk drive:


# mount -l

/dev/hda10 on / type ext3 (rw) [/]
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/hda2 on /boot type ext3 (rw) [/boot]
none on /dev/shm type tmpfs (rw)
/dev/hda3 on /home type ext3 (rw) [/home]
/dev/hda7 on /opt type ext3 (rw) [/opt]
/dev/hda11 on /tmp type ext3 (rw) [/tmp]
/dev/hda5 on /usr type ext3 (rw) [/usr]
/dev/hda9 on /usr/local type ext3 (rw) [/usr/local]
/dev/hda8 on /var type ext3 (rw) [/var]
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
#

# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda10            2.0G  146M  1.7G   8% /
/dev/hda2             981M   21M  911M   3% /boot
none                 1006M     0 1006M   0% /dev/shm
/dev/hda3              14G   67M   13G   1% /home
/dev/hda7             3.9G   40M  3.7G   2% /opt
/dev/hda11            3.6G   40M  3.4G   2% /tmp
/dev/hda5             5.8G  2.8G  2.8G  51% /usr
/dev/hda9             2.0G   36M  1.8G   2% /usr/local
/dev/hda8             3.9G   93M  3.6G   3% /var
#

# fdisk -l

Disk /dev/hda: 137.4 GB, 137438952960 bytes
255 heads, 63 sectors/track, 16709 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1       11519    92526336    c  W95 FAT32 (LBA)
/dev/hda2           11520       11646     1020127+  83  Linux
/dev/hda3           11647       13431    14338012+  83  Linux
/dev/hda4           13432       16709    26330535    5  Extended
/dev/hda5           13432       14196     6144831   83  Linux
/dev/hda6           14197       14706     4096543+  82  Linux swap
/dev/hda7           14707       15216     4096543+  83  Linux
/dev/hda8           15217       15726     4096543+  83  Linux
/dev/hda9           15727       15981     2048256   83  Linux
/dev/hda10          15982       16236     2048256   83  Linux
/dev/hda11          16237       16709     3799341   83  Linux
#

Dual Boot Links

The following general links are useful references when partitioning a disk and setting up a dual-boot system:

URLSummary/Description
http://www.linuxclues.com/articles/10.htm Creating a Linux boot disk
http://www.yolinux.com/TUTORIALS/LinuxTutorialRedHatInstallation.html Fedora Core and Redhat Linux CD Installation
http://www.dedoimedo.com/computers/grub.html Grub bootloader - Full tutorial
http://sourceforge.net/project/showfiles.php?group_id=115843&package_id=173828 Gparted
http://apcmag.com/dualboot The Definitive dual-booting Guide: Linux, Vista and XP step-by-step
http://www.trombettworks.com/multi-boot.htm The REAL Multi-boot site
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=11181&forum=27 Partition layout for XP, Centos3 & Centos4 on same disk
http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html Linux System Configuration and Administration, a multitude of topics are covered in this excellent resource
http://www.brennan.id.au/index.html Linux Home Server HOWTO
http://halisway.blogspot.com/2006/05/installing-centos-linux-on-remote.html Guidance for installing Linux on a remote machine