# FreeBSD overwrites MBR.



## elias (Jun 17, 2011)

Dear FreeBSD users,

  I have succefully installed FreeBSD in a shared disk with Windows 7. The problem is that even if I tell FreeBSD *not* to touch MBR, it does. And it ends up loading only FreeBSD without having the select option. Then I tried installing it using the FreeBSD's booting manager. Now I have the option but when I choose Windows 7, I get the damage errors. My goal was not to touch MBR, and then login to Windows usings EasyBCD and make things easy but without result. Is this a bug?

I am using the amd64 version, 8.2-RELEASE.

Thank you for your time.

(I have to add that I don't have any experience with UNIX-like operating systems)


----------



## da1 (Jun 17, 2011)

It's a bug. I have submitted a PR (http://www.freebsd.org/cgi/query-pr.cgi?pr=157635) some time ago but no action has been taken so far.


----------



## Beastie (Jun 17, 2011)

It's a bug that has existed since forever. As I expected before even checking the PR the priority on fixing it is low since it really only affects systems that are dual booting with Windows as far as I know.

You can easily avoid the problem by backing up/writing down the partition table (specifically the CHS coordinates of the Windows slice(s)) before installing FreeBSD and restoring the information if Windows can't load afterwards.
Or you can try this.


----------



## elias (Jun 17, 2011)

Beastie said:
			
		

> It's a bug that has existed since forever.



Many people seem to have the same issue. 



			
				Beastie said:
			
		

> You can easily avoid the problem by backing up/writing down the partition table (specifically the CHS coordinates of the Windows slice(s)) before installing FreeBSD and restoring the information if Windows can't load afterwards.



It's easy to say, but I am a Windows guy with no experience in commands. You may have the background and  it is an easy task for you. I've read your advice on the link, but I don't know if it will fix my problem and I hesitate to try it with no results for a 6th installation in a day.... If something goes wrong, I don't know how to fix it!


----------



## wblock@ (Jun 17, 2011)

Clonezilla will back up the MBR and partition table in addition to everything else; always a good idea before messing with a disk's MBR.  There must be some Windows backup software that can easily save the MBR, but I don't know of it.

Don't try this without a full backup, MBR and the entire disk also.
/dev/ad0 is shown, but substitute your device.

To back up the MBR with FreeBSD, it's just (untested, lately)
`# dd if=/dev/ad0 of=mbr.bak bs=512 count=40`
(Why 40 blocks?  In case it's GPT.)

Writing it back is about the same, although the GEOM safety needs to be turned off:
`# sysctl kern.geom.debugflags=16`
`# dd if=mbr.bak of=/dev/ad0`

Of course, if the MBR has been blown away, booting into FreeBSD might be a problem also.  mfsBSD works well for that.


----------



## elias (Jun 17, 2011)

wblock, Windows 7 is installed, so by installing FreeBSD there is no reason to back up the MBR after that, FreeBSD has already destroyed it.


----------



## wblock@ (Jun 17, 2011)

elias said:
			
		

> wblock, Windows 7 is installed, so by installing FreeBSD there is no reason to back up the MBR after that, FreeBSD has already destroyed it.



Boot from the Windows recovery partition or Windows CD that the manufacturer probably didn't supply, get to the "recovery console", and use fixboot or fixmbr.

Then use EasyBCD to set up the boot menu.


----------



## cyberastr (Jun 18, 2011)

Hello first post from me 

I hope I can help here.

The fixboot or fixmbr is worth trying, however may do nothing so you can:

1. Burn an ISO image of the Ultimate Boot CD **Windows version** (it's a bootable CD with disk tools and such)

2. Boot from CD. You probably won't have to press anything during the booting process

3. A main menu appears (look here for the menu screenshot and link to download ISO http://mrbass.org/ubcd/)

4. Under the F3 option (File system tools) select the MBRWork v1.07b tool

5. Also here you do not have to press anything (the tool is loading), except at the last "window" that appears. (you'll know when you see it)

6. 
i)  So after that it opens the menu of the tool you selected. 
ii) Press the option to select active partition. 
iii) Select one of those and then select the exit option. 
iv) Restart manually.

7. If you are lucky you chose the Windows partition. If not then you can boot again the CD and then the same tool and select another partition. 
(I selected 1, first nothing happened, then 0, and TA DA!! Windows)

Note: I do not guarantee that this will work 100% but it did for me, try as a last resort solution, because there is always a small chance that this type of "advanced" solution may result in a completely unbootable disk. Also I do not know that you will be able to boot again on FreeBSD if this works, but you can install easyBCD up to that point as mentioned above. Good luck!


----------



## carlton_draught (Jun 18, 2011)

cyberastr said:
			
		

> Hello first post from me
> 
> I hope I can help here.


Hi, welcome and thanks for joining the forums. I hope you continue posting here.


----------

