# MBR issue?



## rhish (Nov 21, 2012)

120GB HD.
1st partition, 40GB, has WinXP installed, everything works as expected. When the laptop boots, it shows Windows loader and loads fine.

I put FreeBSD 9.0 install CD in and try to install, it shows an old partitioning scheme I used in the past, using the entire disk. Nothing shown about the WinXP 40GB partition currently being used.

So I go into shell. 
[cmd=]# fdisk[/cmd]


```
Figures below wont work with BIOS for partitions not in cyl 1
```

So I do a [cmd=]# gpart show[/cmd]
It shows the old partition scheme from before I wiped and re-installed winXP. That old partition scheme used the entire disk. The main headline says [CORRUPT]
Is the main mbr corrupt, and so it reads the "backup" mbr from somewhere?

How do I reset all of the boot/mbr stuff, retaining the 40GB partition with WinXP in it, and then install FreeBSD 9.0 in the remaining 70GB?

Have I given enough information? Let me know if I need to provide more info.

thanks


----------



## wblock@ (Nov 21, 2012)

If you had shown the gpart output, we could tell if it was finding an old GPT backup partition.


----------



## kpa (Nov 21, 2012)

Corrupt MBR is usually a result from manual tinkering of the partition table or buggy partitioning tools, I would back up everything with for example Clonezilla (back up individual partitions, not the whole disk) and recreate the partitions with gpart(8) and restore the backup.


----------



## rhish (Nov 21, 2012)

Yes, I remember it saying the "primary"? was corrupt and so it is using the "secondary". The problem i'm having is, how do I either fix the corrupted Primary, or reset it to a "factory default" state?


----------



## rhish (Nov 21, 2012)

Kpa, that is very likely. I have installed multiple, different, OS multiple times. I've played with partitions several times in different situations. I'm sure the issue was self inflicted. It's an older Laptop I use for learning, experimenting, etc. I'm just trying to figure out how I return the drive/partitions to a default state. What I'm hoping to do is restore it to some "factory default" type state, and then start over. Preferably, preserving the current 40GB WinXP partition, in partition 1, if possible. If not, I can live with a reinstall. 

Lets say I'm going to wipe the entire drive and start over. How would I reset everything before I reinstall everything? It would seem I'm either not doing it right, or I'm missing something.


----------



## rhish (Nov 21, 2012)

If I use the WinXP Recovery to Fixmbr, Fixboot, shouldn't that reset the primary mbr to a proper state? FreeBSD doesn't seem to see the MBR at all. So its using the secondary. But, if the Primary is messed up, wouldn't that prevent Windows from working too? Windows loads fine.


----------



## wblock@ (Nov 21, 2012)

Step 1 would be to identify whether it's a MBR or GPT.  You don't say what the "old" installation was, and there's still no gpart output, so I can only guess it was a backup GPT table.  In that case, erasing the last 34 blocks of the drive is enough.

XP's fixboot/fixmbr won't help, since the problem is not in an MBR.  Well, maybe, it's all guesswork without any evidence.


----------



## rhish (Nov 22, 2012)

Sorry for the confusion. Its a GPT table, primary is corrupt, so it reverts to the secondary, which has an old scheme.
Im just going to try and recover and then wipe and start over. 
Thanks for the suggestions, sorry it was confusing.


----------



## wblock@ (Nov 22, 2012)

In that case, you need to remove the old secondary GPT.  Make a full backup first.

Boot FreeBSD, or if it won't boot, use an mfsBSD CD or memory stick.

From the newly-updated Disk Setup On FreeBSD:



> Removing secondary or backup GPT table at the end of the disk requires a little calculation. Use diskinfo(8) to get the number of blocks, subtract the 34-block length of the standard table, and write from there to the end of the disk. In this example, the disk has 60030432 blocks. Subtracting 34 from that gives 60030398 as the starting location, and dd(1) will write from there to the end of the disk.
> 
> 
> ```
> ...


----------

