# How to install FreeBSD on some older motherboards using MBR or GPT disks



## petrek (Dec 26, 2014)

First some background. For historical reasons (a bug in Windows95 and some ealier OSes from Microsoft), some BIOSes, to keep compatibility, can only handle disks up to 255 heads and hang when they have to deal with more than that. FreeBSD (probably at least in gpt_write_mbr_entry from sys/geom/part/g_part_gpt.c file) sets the head address of the last absolute sector as 0xff (255 in decimal). Since heads are counted from zero, this means 256th head and problems. If you've encountered this (it affects both MBR and GPT partitioning schemes, and setting active partition doesn't help) and still want to use FreeBSD with such motherboard you'll need to do as follows (assuming you're using FreeBSD 10.1, in other versions vi commands may be different):

(Short notice: read the whole how to before you proceed with the actual installation, and *back up* your disk first!)

To repair the disk, you need to clear the first sector of it:

`dd if=/dev/zero of=/dev/NameOfYourDeviceNode bs=512 count=1`

Now proceed normally with the installation. At the end, when installer will ask you if you want to make some changes, choose yes.

Next (assuming your disk is ada0, change this if it's something else):

```
# dd if=/dev/ada0 of=/tmp/pmbr bs=512 count=1
# vi /tmp/pmbr
```

In vi, you should see \xff\xff\xff near the end of the file (if you see it two times, it's the second one, I guess ).
Type `/^xff^xff` to get to the first char - which means first \xff (some explanation if you're not familiar with vi, in the command mode first press / after that press Ctrl key together with x, and then two times f. And then repeat: Ctrl + x, f, f).
Now press x to delete the char you're on, press i to get into the text mode, press Ctrl + x and then f, e. You should see \xfe\xff\xff (only two \xff's, if you still see three delete one of them).
Press Esc key to get back into the command mode, and save the file (for example press z key twice while holding Shift).
Now run

```
# sysctl kern.geom.debugflags=0x10
# dd if=/tmp/pmbr of=/dev/ada0 bs=512 count=1
```
(once again, you should change ada0 if your disk shows under different name) and voila, your installation should work well now. But be careful, backup everything before start, just in case you'll make some mistake.


----------

