# Building a stripped down kernel



## NatashaX (Aug 23, 2018)

I am building a web server out of a old HP ML350 G5 server with 1 Quad Xeon and 8 GB of FBDIMM. This box also has 6x 146 GB 15k RPM SAS drives in raid 5.
I would like to know how to build a kernel for only the installed hardware in the machine only.

Can anyone please help me?
Thanks


----------



## SirDice (Aug 23, 2018)

If you have to ask this question I would suggest simply sticking to a -RELEASE kernel. There's very little to gain by building a custom kernel and it's going to make updating more involved. Most people are able to use the GENERIC kernel without issues.


----------



## kpa (Aug 23, 2018)

Not worth it, seriously. Building a customized minimal kernel was a good practice at the time when machines had limited memory and you could actually gain more performance by having more free memory. Now it's just an academic excercise because the gains are on magnitudes of few dozens of megabytes. FreeBSD leaves all drivers that have no device to latch on to uninitialized so they don't actually waste any memory other than what is taken by the loaded in inert code.


----------



## ShelLuser (Aug 23, 2018)

Definitely not worth the effort. That is: not if your goal is merely to "optimize" the kernel because, as already mentioned by the others, there is hardly anything to gain here.

But to actually answer the question: read the FreeBSD handbook, in specific chapter 8 which explains the whole process.


----------



## OldBlue (Aug 30, 2018)

I think the key word here is 'old' and a reference to some raid that is no longer supported by the kernel.  That is my predicament and I want to try a custom kernel before spending some money on a replacement sas card.

Thank you for the links.

[first post!]


----------



## leebrown66 (Aug 31, 2018)

If I remember correctly, that HP uses a proprietary RAID card.  I was excited many years ago to get a used one of these, only to chuck it out as I simply could not access the disks.  I think it was locked into to RAID5 as well.  You might be able to pull off some voodoo and reflash it, provided it's actually a supported card, like LSI for example.

Best of luck.


----------



## SirDice (Aug 31, 2018)

If this is an LSI card you may run into issues, most of the older cards are supported by mfi(4), some cards are supported by both mfi(4) and mrsas(4), and some cards (especially newer cards) are only supported by mrsas(4). 

The problem however is that the mfi(4) driver takes precedence over mrsas(4) and mfi(4) will fail to detect the newer cards. The trick is to set `hw.mfi.mrsas_enable`: 


```
Using /boot/device.hints (as mentioned below), the user can provide a
     preference for the mrsas driver to detect a MR-Fusion card instead of the
     mfi(4) driver.

           hw.mfi.mrsas_enable="1"

     At boot time, the mfi(4) driver will get priority to detect MR-Fusion
     controllers by default.  Before changing this default driver selection
     policy, LSI advises users to understand how the driver selection policy
     works.  LSI's policy is to provide priority to the mfi(4) driver to
     detect MR-Fusion cards, but allow for the ability to choose the mrsas
     driver to detect MR-Fusion cards.

     LSI recommends setting hw.mfi.mrsas_enable="0" for customers who are
     using the older mfi(4) driver and do not want to switch to mrsas.  For
     those customers who are using a MR-Fusion controller for the first time,
     LSI recommends using the mrsas driver and setting
     hw.mfi.mrsas_enable="1".
```
See mrsas(4).


----------



## leebrown66 (Aug 31, 2018)

I threw that machine out pretty quickly.  I'm not sure it was even possible to flash the card with anything except HP's signed code.  Like Dell servers, they are made to tight specifictions, for a specific purpose and unfortunately FreeBSD isn't on their radar.


----------

