advertisement

Hack:   Hack the Windows NT/2000/XP Boot Loader
Subject:   TWO DRIVES WORKING
Date:   2005-07-23 17:13:43
From:   paisley
OK I have this working with two drives using the Windows XP boot loader - WindowsXP on hda2 and Linux on hdc1.


Here is my setup:


/dev/hda1 DOS (Fat16)
/dev/hda2 WindowsXP (NTFS)
/dev/hda3 Data (NTFS)



/dev/hdc1 Linux-boot ext2
/dev/hdc2 Linux-swap
/dev/hdc3 Linux-root reiserfs
/dev/hdc4 Windows2003Svr (NTFS)



I originally had the Windows boot loader installed on /dev/hda MBR. I also had the Grub boot loader installed on /dev/hdc MBR. Both environments booted separately using the Laptop BIOS boot device selection options. However, just like the previous postings I couldn't get the Windows boot loader booting Linux on the second drive.


This is because Grub stage1 (512 byte MBR code) hard codes the location of Stage2 in drive and block list format. You must obtain this information to create a suitable stage1 binary for the Windows boot loader. (I'm referring to the C:\linux.bin)


The easiest way to create a suitable Grub stage 1 is to install it on the MBR of the Windows drive temporarily, copy it and then restore the Windows boot loader.


Here are the steps to do just that (you will need to modify to suit your partition setup):


***Please be careful as Grub partitions are indexed from 0 (hd0,0) and Linux indexed from 1 (/dev/hda1)!!!


1. Establish a way to boot each environment separately (I am using a Laptop so I use the BIOS for this, but you could use boot disks, CDROM, USB etc). Also back up ALL your boot records using dd. e.g "dd if=/dev/hda bs=512 count=1 of=/mnt/usb/backup/hda", "dd if=/dev/hda1 bs=512 count=1 of=/mnt/usb/backup/hda1" .... and so on


2. a) Boot into Linux or a Linux boot CD and setup Grub onto /dev/hda MBR
#grub
grub> root (hd0,0)
grub> find /boot/grub/stage1
grub> setup (hd0)


***Do NOT install Grub onto a partition (hd0,0) especially the Windows partition as this will erase the NTLDR. Install onto the MBR (hd0) as this is easily restored in step 4.


2. b) Setup Grub to run from the new location (from Windows):
Edit /boot/grub/grub.conf and update the splashimage location or you will get a blank/distorted screen
i.e. splashimage=(hd1,0)/grub/splash.xpm.gz
Edit any other references such as root(hd1,0), initrd that will also need to change


***In theory you could now reboot and get Grub to boot both OS's however the aim is to get Windows boot loader to do that so we will continue...


3. Copy the Grub stage 1 onto some sort of removable media
#dd if=/dev/hda bs=512 count=1 of=/mnt/usb/linux.bin


4. Restore the Windows boot loader.
-Boot WindowsXP Install CD and select repair option
-Select the Windows platform in the recovery console and enter admin password
-Type fixmbr


5. Reboot into WindowsXP
-Copy the image stored on the removable media to the C:\ drive
-Modify the boot.ini as per article above:
C:\linux.bin="Linux"


6. Reboot and use the Windows Boot Loader to boot either Linux or Windows on separate physical disks!!!



Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • TWO DRIVES WORKING
    2006-04-06 04:31:00  Degash [Reply | View]

    i want the first step to take.Do i have to instor xp and then the next drive after.or i have to make one master and the order one slave.pls help

Showing messages 1 through 1 of 1.