The Windows installer writes the windows bootloader to the mbr. 'grub-install /dev/sda' or suchlike writes grub to the mbr. Only one thing can be in the mbr. To avoid this, you can try to install grub to a partition, but that can be tricky.
The following won't work in Mac OS, and can do very band things to your drive if not done right. If you want to save your MBR so you can 'undo' any mistakes (aka, overwriting the windows bootloader), run the following command:
Code:
sudo dd if=/dev/sda of=<somefile> bs=512 count=1
This will save the MBR of the first drive to the file <somefile>. Note that this will not work on a partition (sda1, sda2, etc). Run the following to restore your mbr to your HD:
Code:
sudo dd if=<somefile> of=/dev/sda bs=512 count=1
When running this last command, be careful not to change anything, unless you know what you are doing. This command writes <somefile> to the first sector of your HD, clobbering whatever might have been there (the MBR almost certainly). If you write gibberish here, Windows and/or grub will no longer boot (without other tools like UBCD). Make sure <somefile> is the same file you created with the first command.
Theory:
The first sector of your drive is your MBR. As far as I know, all modern HD's have a sector size of 512 bytes. Thus, the first 512 bytes of your drive are your MBR. Your MBR stores the BIOS bootloader and partition table for your HD.
The command 'dd' performs a byte for byte copy. 'if' stands for input file. 'of' stands for output file. 'bs' means block size and 'count' specifies how many blocks of size bs the command will copy. When the output file is your HD (/dev/sda), you are writing to your HD and can break things if you are not careful. To read or write your MBR, you want the first 512 bytes of your HD, so bs * count = 512 is necessary. Simply, 'bs=512 count=1' or 'bs=1 count=512'. If you leave off count, the command will read or write until it reaches the end of your hard drive (bad). Both of these commands should end quickly and output on of the following:
'bs=512 count=1':
Code:
1+0 records in
1+0 records out
512 bytes transferred in 0.019265 secs (26576 bytes/sec)
'bs=1 count=512':
Code:
512+0 records in
512+0 records out
512 bytes transferred in 0.022546 secs (22709 bytes/sec)
Bookmarks