To restore the "standard" Windows MBR code, you can use the Recovery Console. That will allow Windows XP to boot (using NTLDR) but not Linux. Normally one would only do this when uninstalling Linux.
To restore the Windows MBR, boot from your Microsoft Windows XP Setup CD. If you have only a CD from Gateway, Dell, etc. then you can download a set of floppy disks from the Microsoft site. Boot from the CD or floppy disks and select the options to use the Recovery Console (not automatic repair).
Enter this command to restore the Windows Master Boot Record.
You do not have to install LILO to the Master Boot Record. You can install LILO to the partition boot sector for the Linux root partition. If you want LILO to boot first instead of Windows NTLDR then use the "fdisk" or "cfdisk" program in Linux to change which partition is the active "Boot" partition. To boot Linux first, make the Linux partition the "Boot" partition and remove the "Boot" designation from the Windows partition. Since you can't boot Linux until you do this, use a Linux boot CD to run "cfdisk" or "fdisk".
As mentioned in the previous post, you can add Windows to the LILO boot menu. You can also add LILO to the Windows boot menu, though it is more complicated. The advantage is that you can boot Windows NTLDR first and then select LILO. Depending on which partition is the "Boot" partition you can have either LILO or Windows NTLDR start first.
Here are the steps involved in adding Linux to the Windows XP boot menu.
Boot Linux and make a copy of the Linux root partition boot sector after installing LILO. You will have to repeat the following steps every time you change your LILO boot configuration or kernel image. I've found that GRUB is a little easier to deal with since you only have to do these steps once.
This is the Linux command to copy the Linux boot sector to a file.
dd if=/dev/hda2 of=/tmp/bootsect.lnx bs=512 count=1
Replace the "hda2" with the correct device name for your Linux root partition.
Next you have to transfer the file "bootsect.lnx" to your Windows XP partition's root directory. One way to do that is using a floppy disk. Another way is to use a partition such as FAT32 that both operating systems can access.
If your Linux partition is on the first hard disk (not first drive letter!) then you don't have to modify the file. If Linux is not on the first hard disk, then you have to change the drive identifier in the file.
Add the Linux boot sector file to your Windows boot menu. Remove the read-only attribute from the file "boot.ini" in the Windows root directory. That's a hidden file, so turn on the option in the folders to show hidden and system files. Use notepad to edit "boot.ini".
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP" /fastdetect /NoExecute=OptOut
I showed the lines that you add or change in bold. The timeout can be any number of seconds, and 0 will not display any menu (you have to press F8 for the menu).
How can you patch the boot sector file for a different drive ID?
One way is to edit the file with the "debug" program in Windows.
Use this command to start the debug program.
Then use the (lower case L) "l" command to load the data into memory.
Use the "e" command with an offset to enter new data for the drive ID. The offsets start at 100 hex, so offset 0 in the sector is offset 100 in the debug program.
After you are done editing the data, write it back to the boot sector file and exit the debug program.
Drive IDs are 0x80 for the first hard disk, 0x81 for the second hard disk, etc. And, I do mean hard disk, not drive letter. If letters C, D and E are all on the first hard disk then you use 0x80 for all of them and do not need to patch the boot sector.
Unfortunately the byte that you patch depends on the version of LILO. In some cases you may not even need to patch it because it may be correct. If you want you can try the boot sector file and then patch it if it doesn't work for Linux on some other hard disk.