# FreeBSD 8.3 corrupting MBR partition table after installation



## razor11 (Apr 22, 2012)

Before installation screenshot from ubuntu live CD

http://i.imgur.com/YIlpA.png

After installation screenshot from ubuntu live CD

http://i.imgur.com/AJm8B.png


----------



## Beeblebrox (Apr 23, 2012)

1. Most likely you are specifying the partitions incorrectly during install. I've seen such error before and it was due to incorrect slice naming. Your FreeBSD partition for sda in FreeBSD notation is ada0s4 (slice #4). Then, to further partition s4 into FreeBSD usable sections you need to set a,b,e etc sections.

2. If you are not going to use windows, why on earth are you using MBR?? Use GPT much more straight-forward. Create the partitions you want under FreeBSD where /root becomes ada0p4 then the rest goes on as p5, p6, etc.

3. If you use ZFS in FreeBSD you won't have to mess around with any partitioning mumbo-jumbo. Linux can read/write to ZFS so you can share /home through it. FreeBSD is able to use swap partition when formatted as linux-swap, so you only need one swap partition.


----------



## wblock@ (Apr 23, 2012)

It's not clear, but I think the problem being suggested is after installing FreeBSD, the existing Linux partitions look wrong according to a Linux tool.

My guess is that FreeBSD adjusted the heads/cylinders/sectors value for the drive.  Remember the sysinstall question about that?  It's meaningless information, but apparently the Linux tools pay attention to it.  Everything should still work, but I haven't tested it.


----------



## aa (Apr 24, 2012)

FreeBSD's sysinstall, bsdlabel, as well as opensource's partition manager like acronis, gparted and many other, inherit the same code bug (maybe from Ranish Partition Manager). They set head/sector start as -1 (255 and 63 respectively) for partition located at cylinder beyond 1023, when they should be 0/1 for primary and 1/1 for extended. The only program I know that handles them correctly is PowerQuest/Symantec Partition Magic.

As long as an application only use LBA value it won't be any problem though, but when partitions get resized and C/H/S values takes into account, the size mismatch, severely.

When you used sysinstall or bsdlabel, you must repair the Head/Sector values to 0 and 1, at MBR and all subsequent extended-partition linked-list.


----------



## razor11 (Apr 28, 2012)

Is it possible to fix this in the bsd FreeBSD installation itself?

Is there any guide explaining how to install FreeBSD using ZFS? I am new to FreeBSD and I have only one hard disk with Linux partitions and lots of data so don*'*t want to risk anything.


----------



## tingo (Apr 29, 2012)

To be on the safe side; don't try to install an operating system you are unfamiliar with on a machine with valuable data.
Some options
1) install on a spare machine, if possible
2) make sure you have a good backup first
3) install on a different hard drive (if possible, remove the hard drive with the valuable data before trying to install something


----------



## razor11 (Apr 29, 2012)

That is why I was trying it first in virtualbox. I simulated 3 linux partitions that I have in my machine and rechecked them after installation. Luckily I found out the problem within virtualbox itself 

I was able to solve the problem by 

1. Booting into Ubuntu Linux and creating a primary partition with the type as 'a5 - FreeBSD'


```
Disk /dev/sda: 27.8 GB, 27796701184 bytes
255 heads, 63 sectors/track, 3379 cylinders, total 54290432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa5991122

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    16779263     8388608   83  Linux
/dev/sda2        16779264    18876415     1048576   82  Linux swap / Solaris
/dev/sda3        18876416    20973567     1048576   83  Linux
/dev/sda4        20973568    54290431    16658432   a5  FreeBSD
```

I used PCBSD instead of FreeBSD since the installer doesn*'*t corrupt the partition table. In the PCBSD graphical installer during the "Disk" option just selected the above FreeBSD partition, clicked on Next and continuted the installation. Now, PCBSD installer won*'*t even touch the MBR boot loader which is what I wanted. Once the installation is over, I reboot and Grub2 is still there and I was able to boot into Ubuntu Linux as before, although I didn*'*t see the FreeBSD entry.

Once inside Ubuntu Linux opened the terminal and tried to do *update-grub*. This didn*'*t work and it failed to auto-detect PCBSD. I had to add the entry for PCBSD manually:

1. Edited the file /etc/default/grub and changed the following entry:


```
GRUB_DEFAULT_TIMEOUT=10
GRUB_HIDDEN_TIMEOUT_QUITE=false
```

2. Edited the file */etc/grub.d/40_custom* and added the following:


```
menuentry "PCBSD" {
  set root=(hd0,4)
  chainloader +1
}
```

Note that the value of root is (hd0,4) where the corresponding FreeBSD partition is /dev/sda4.

You need to run *update-grub* again after step 2 before rebooting. Now reboot and you will see the PCBSD entry in the grub selection. Enjoy.


----------



## razor11 (May 6, 2012)

I have finally managed to installed PCBSD 9 on my system and everything went great


----------

