# FreeBSD 9 on HP DC 5850



## jkxx74 (Apr 2, 2012)

Note: This is a guide on how to get FreeBSD working on this machine. 

Long story: Newegg was selling these at a very low price of $135 shipped and I picked one up, immediately envisioning a new leaner router for my home network. Later research showed this would be a problem as the HP BIOS causes the BTX loader to hang. (See http://lists.freebsd.org/pipermail/freebsd-stable/2011-June/062952.html and http://lists.freebsd.org/pipermail/freebsd-bugs/2010-March/038758.html.

The problem: The hang is due to the btx binary, which is embedded into the file /boot/loader as part of the boot process. boot0, 2, and the rest of loader are unaffected. Nevertheless this hang causes FreeBSD 7+ to not boot at all on similar HP hardware.

The fix: The fix (worked for me!) is to take an older BTX 1.01 binary and embed it into an otherwise *Free*BSD 9 /boot/loader, leaving all other components the same. This is then sufficient to successfully boot up the i386 kernel. The amd64 kernel still won't boot up due to HP providing a broken memory map in their BIOS.

Instructions:

FreeBSD9 on HP DC5850

1. Only works with FreeBSD9-i386. The btx.S file from FreeBSD 6.2 is needed.
1a. The DC5850 needs to have a DVD drive, and the FreeBSD 9.0 (i386) needs to be inserted into the drive

2. Set up a 6.2 system (in a VM) and obtain the btx.S file from there. The VM FreeBSD must have network access and then the file can be transferred using SMB, NFS, FTP, or protocol of your choice.

3. Install FreeBSD 9 i386 in a VM, then move the older btx.S (from above) to /usr/src/sys/i386/btx/ and compile everything under /boot. The two important files from here are /boot/loader and /boot/pxeload

3a. I have uploaded copies of these two files at http://jkansoft.mine.nu/bsd9_dc5850/. Feel free to use these if you are not up to setting up the two different FreeBSD systems to create them.

4. Create an NFS shareable *Free*BSD 9 directory following instructions from http://jdc.parodius.com/freebsd/pxeboot_serial_install_8.html
   (other relevant instructions at http://www.locolomo.org/howto/pxeboot/article.html )

For above step, I had to use 7-zip from a Windows host and copy the extracted files (from *Free*BSD 9 ISO) to the directory. Then the pxeboot and loader files were updated with the two generated above.

Note that the NFS share must be mounted rw. This allows install to start but will cause problems if actually trying to install from NFS.

5. PXE boot the DC5850 but escape to loader prompt when option is given. Enter the commands

`vfs.root.mountfrom.options=rw`
`boot`

to successfully get the installer to load.

6. Choose Install from CD-DVD and make sure the installer can read from the FreeBSD 9 DVD in the drive.

7. Install to hard drive in DC5850.

8. Mount the NFS filesystem, or if mounted locate where it is mounted and copy the /boot/loader file from there to the same directry in the new install on the HDD. This is necessary since the modified loader contains the working BTX and the install will install the non-working btx from DVD.

9. Reboot and watch the system boot up as usual!

Alternative method

Follow steps 1-3 producing the two files mentioned. Install FreeBSD 9 to the target HD using a working PC without loader booting problems. Then update just the /boot/loader file on the finished install and reboot.

The alternative method did it for me, although the NFS way will work for people willing to spend some time debugging NFS.

If anyone has any suggestions to improve the instructions, feel free to post them here.


----------



## wblock@ (Apr 2, 2012)

Has a PR been entered for this?


----------



## jkxx74 (Apr 2, 2012)

*PR*

I believe the PR would be this one - http://www.freebsd.org/cgi/query-pr.cgi?pr=144437

I found several bits and pieces of information on it, and the conclusion was the BIOS in the machine is so bad, it will only support calls necessary to boot Windows (and apparently the older BTX.) I do have one so could try to do some testing if there is interest in that.


----------



## jkxx74 (Apr 3, 2012)

*Update*

One more update from me. It seems the BIOS caused one extra issue, that being improper installed memory detection. The machine has 2 GB, but the FreeBSD kernel is detecting (usually) only about 44 MB. Naturally this will cause issues quickly. It is easily remedied by editing /boot/loader.conf and inserting the following two lines (this is on a machine with 2 GB of RAM. Note that G and M suffixes are acceptable as well; use a number slightly less than the actual RAM available for safety's sake):


```
hw.physmem=2000000000
hw.realmem=2000000000
```

The physical memory portion might be sufficient by itself. I have been doing some heavy compiling and seen no issues but will update this if anything crops up.

P.S. Shame on HP for the BIOS implementation.


----------



## dadak (Feb 9, 2015)

Hi, i'm trying to install pfSense 2.2 on a HP DC 5850 using an USB key.
The image used is pfSense-memstick-2.2-RELEASE-i386.

At starting, it gives the following messages, and it hangs :

```
0F0001 FEg Boot From USB Device
   BTX Loader 1.00 BTX version is 1.02
```
There's a red blinking light, and the buzzer rings.

pfSense 2.2 is based on FreeBSD 10.1, and the BTX version is 1.02 ...

I've updated to the latest BIOS version (v3.14) and it still happens.
I've also set the SATA controller emulation to native IDE.

Because pfSense 1.2 is based on FreeBSD 6.2, I've tried to install pfSense 1.2 Live CD, and I hoped I could upgrade later to the latest version of pfSense. The install needs two ethernet adapters to achieve. But this version of pfSense does not support the onboard ethernet card (bge0 on DC5750) and there is only one PCI slot on the DC5850, so it can only detects one ethernet adapter, and the install cannot be completed.

Then I've tried to mix pfSense 1.2 and 2.2 on the USB boot key.
I've tried to replace some files of 2.2 by ones of 1.2 :

```
/boot/loader
   /boot/pxeboot
   /boot/loader.rc
   /boot/defaults/loader.conf
```

Then it boots, but just before the system will run there are some errors.

```
Trying to mount root from ufs:/dev/ufs/pfSense []...
   Configuring crash dumps...
   Mounting filesystems...
   Generating MFS /var partition
   Generating MFS /etc partition
   g_vfs_done():md2[Write(offset=xxx, length=xxx)]error = 28
```

It should be

```
Generating MFS /var partition
   Generating MFS /etc partition
   Looking for pfi.conf on acd0c done.
   ...
```

Any suggestions to achieve installation ?
Thanks in advance.


----------



## junovitch@ (Feb 10, 2015)

A word of warning that this is not a pfSense forum and not the best place for support.
https://forums.freebsd.org/threads/pc-bsd-freenas-nas4free-and-all-other-freebsd-derivatives.7290/

Given what you have shown there may be some incompatibilities or regression with the FreeBSD loader on that hardware.  Those are pretty old systems right?  What I would do is probably try to get a baseline and see what OS versions work.  Try downloading memstick images from various recent FreeBSD versions and see what works and doesn't.  Either you've stumbled across a bug that could affect FreeBSD as well or pfSense has some specific changes that make asking on their forums the best thing to do.

http://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/


----------



## dadak (Feb 11, 2015)

It is the only place I find, where someone was able to run a recent version of FreeBSD, normally loaded by a BTX version 1.02 on a HP DC5850. The only solution I found, is here, and it is to replace /boot/loader and /boot/pxeboot from FreeBSD 6.2.
Because pfSense runs on FreeBSD, that's why I posted here.
I think the trouble is specific to FreeBSD not pfSense.
The case 144437 (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=144437) is still in progress since 2010.

So I've made many other tests with FreeBSD this time.

Using FreeBSD-6.2-RELEASE-i386-disc1.iso installation was successful. After rebooting, FreeBSD works fine.
(BTX version is 1.01)

Using FreeBSD-7.4-RELEASE-i386-bootonly.iso, it hangs.
(BTX version is 1.02)

Using FreeBSD-8.4-RELEASE-i386-bootonly.iso, it hangs.
(BTX version is 1.02)

Using FreeBSD-10.1-RELEASE-i386-mini-memstick.img, it hangs.
(BTX version is 1.02)

Using FreeBSD-10.1-RELEASE-i386-memstick.img, and replacing /boot/loader and /boot/pxeboot from FreeBSD-6.2-RELEASE-i386-bootonly.iso
The install launches, after partitioning, after verifying checksums of files (base.txz, kernel.txz ...), it fails at the beginning of the distribution extraction ... I saw base.tgz hangs at 8%;
The console Alt+F3 says

```
DEBUG: Running installation step: distextract
Killed
```
Using FreeBSD-10.1-RELEASE-i386-memstick.img, and replacing /boot/loader, /boot/pxeboot, /boot/loader.conf and /boot/loader.rc from FreeBSD-6.2-RELEASE-i386-bootonly.iso exactly the same result...

Using FreeBSD-10.1-RELEASE-i386-memstick.img, and replacing /boot/loader, /boot/pxeboot, /boot/loader.conf and /boot/loader.rc, /boot/boot0, /boot/boot2 from FreeBSD-6.2-RELEASE-i386-bootonly.iso
exactly the same result ...

I didn't try jkxx74's method to install via PXE, I think that it is a little too complex for me. I still think that it is possible with an USB key to install a recent version of FreeBSD on HP DC 5850 using some files of 6.2... or editing some config files...


----------

