The objective is to boot either XP Home or RedHat Linux using GRUB. This method assumes a working Linux system exists on a separate drive, and in this case a drive that has Linux RAID1 disk mirroring. Disk mirroring is used mainly as an easy way to copy, but copying can be done by mounting the partitions of the disk used for dual booting to the existing Linux drive that was booted from, and manually copying the directories over.
The overall process:
1) blank hard disk in which Windows XP will be loaded from a CD into a partition of under 1020 cylinders *(1).
2) the hard disk will then be installed into a Linux PC as a secondary drive and fdisk setup for the Linux partitions and the optional FAT32 partition, Linux boot partition set, then formatted (mkfs.ext3, etc.)
3) the drive then has the Linux copied to it from the main
Linux drive using either disk mirroring or manual copying by mounting
the partitions to the main drive, then copied using the cp command.
4) a bootable MBR is created on the secondary drive.
5) grub.conf is edited for boot sequence.
*(1) You
could also partition the empty drive in Linux, format Linux and FAT32
partitions, then install XP from the CD (Linux cannot format NTFS at
the time of this writing, kernel 2.4.28) with the drive on the primary
IDE.
The PC is a standard Dell Dimension 2400 in which the primary OS to boot is Linux, as a backup server and for testing. Occasionally, Windows functionality is desired and so the XP Home that came with the PC will be a boot-up choice.
The Dell Dimension 2400 came with a 40 GB hard disk. XP wants to be the first partition (/dev/hda1) and so as a second drive, partitioned using fdisk in Linux as follows (not all of the disk is utilized):
The current Linux (2.4.28 kernel?) can read NTFS partitions, but not write them.
Disk /dev/hda: 255 heads, 63 sectors, 4863 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 893 7172991 7 HPFS/NTFS
/dev/hda2 * 894 906 104422+ fd Linux raid autodetect
/dev/hda3 907 4863 31784602+ 5 Extended
/dev/hda5 907 2800 15213523+ fd Linux raid autodetect
/dev/hda6 2801 2866 530113+ fd Linux raid autodetect
/dev/hda7 2867 3010 1156648+ c Win95 FAT32 (LBA)
/dev/hda1 was made 7GB to keep under the BIOS 1024 cylinders (a restriction on some PCs for boot partitions, the addressable range of the INT13 interface) and also got the /dev/hda2 (Linux /boot) within the 1024 cylinders. Note that /dev/hda2 is shown as being the boot partition (*) in the final configuration, but /dev/hda1 needs to be the boot partition to install XP. The INT13 functions define 24 bits to describe a sector on the hard disk. This breaks down to a maximum of 256 heads (or sides), 1024 cylinders, and 63 sectors. With these numbers, only 256*1024*63 (or 16,515,072) sectors can be used with INT13 functions. At a standard 512 bytes per sector, this is 8,455,716,864 bytes, or approximately 7.8 GB
The Win95 FAT32 (LBA) partition (/dev/hda7, less than 2 GB) can be read and written by Linux and XP. Linux symbolic links do not work on FAT32, but otherwise can be handy to have.
With the hard disk now as the primary IDE drive and /dev/hda1 as the boot partition, XP was loaded from the CD which also formatted the NTFS partition. XP cannot see the Linux partitions. The Linux and FAT32 file systems were formatted in Linux (mkfs.ext3 for /dev/hda2 and /dev/hda5, mkswap for /dev/hda6, mkfs.vfat for /dev/hda7).
Linux was loaded on the drive by mirroring an existing Linux drive. If you don't have a mirror drive, mount the Linux partitions to the Linux drive that was booted then copy. In the above example /dev/hda2 is the /boot, and formatted EXT3. So, if installed as primary drive on the secondary IDE, the drive would be /dev/hdc.
mount /dev/hdc2 /mnt/dev/hda5 is the root partition (/) and is harder to copy because some directories are special ( /proc, /boot , ...) and you just mkdir instead of copying. /dev/hda6 (in the above example) is the swap partition and does not need to be copied. All Linux directories that exist on other partitions need to exist on the root partition, if only as a mount point (you do mkdir, but don't copy the associated files). In /etc/fstab is where the partition and mount point are correlated at boot-up:
then
cp -Rp /boot/* /mnt/
/dev/md1 / ext3 defaults 1 1
/dev/md0 /boot ext3 defaults 1 2
none /proc proc defaults 0 0
/dev/md2 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0
The above file /etc/fstab may seem confusing because RAID1 is being used. /dev/hda5 became /dev/md1, /dev/hda2 became /dev/md0, /dev/hda6 became /dev/md3 after the raidhotadd command. The RAID configuration is loaded before /etc/fstab.
OK, so at this point XP and Linux should exist on one drive and XP
only would boot when placed as the master drive on the primary IDE.
Set the BIOS so that the boot drive is a floppy or CDROM and place the Linux boot disk in either one selected. Linux will bring you to a shell prompt after doing linux rescue. You will need to know how to use the "vi" editor or some other one.
Make a mount point (mkdir) on /mnt
mkdir /mnt/hda
Now mount the boot partition which is /dev/hda2 in this case
mount /dev/hda2 /mnt/hda
Go to the grub directory (/mnt/hda/boot/grub) and edit grub.conf. GRUB makes the first disk it sees hd0, and first partition 0. So - hd0,1 is /dev/hda2, the /boot partition in this case.
cd /mnt/hda/grub
vi grub.conf
Modify grub.conf making the root (hd0,1)
and adding:
title Windows XP Home Edition
rootnoverify (hd0,0)
chainloader +1
# 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/md1
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,1)/grub/splash.xpm.gz
title Red Hat Linux (2.4.28custom)
root (hd0,1)
kernel /vmlinuz-2.4.28custom ro root=/dev/md1
initrd /initrd-2.4.28custom.img
title Windows XP Home Edition
rootnoverify (hd0,0)
chainloader +1
Again, a mirror drive is normally used, so in "kernel /vmlinuz-2.4.28custom ro root=/dev/md1". Just change the drive where the root partition exists (/dev/hda5 in this case if it wasn't a RAID1 mirror configuration). The word "root" has different meanings in Linux - unfortunately.
After saving the file run:
#grub --batch
>root (hd0,1)
>setup (hd0,1)
>quit
Then use fdisk to change the boot partition from /dev/hda1 (XP Home) to /dev/hda2 (/boot) [selecting hda1 as the boot gets rid of the existing boot * on hda1].
That's it! Re-boot after changing the BIOS boot drive to the hard disk.
Windows Vista Notes:
grub.conf for running Linux & Vista Home Basic on hard disk 0 (hd0) and Windows Vista Ultimate on disk 1 (hd1). Vista wants to be the first disk and partition, so the GRUB loader map command swaps the disks for that purpose. Both Vista Home Basic and Ultimate boot, although the script appears to be wrong for Home Basic.
# grub.conf generated by anaconda