# Howto update system with custom kernel



## kr0m (Apr 7, 2022)

Hello, i have a question about FreeBSD updates when using freebsd-update tool when you are running a custom kernel, in the documentation i can read:


> Always keep a copy of the GENERIC kernel in /boot/GENERIC. It will be helpful in diagnosing a variety of problems and in performing version upgrades


When i compile my custom kernel, the GENERIC ends in /boot/kernel.old directory, i could copy to /boot/GENERIC to mantain a copy the first time.
But some time ago when i have recompiled the custom kernel several times both /boot/kernel and /boot/kernel.old will contain my own kernel and the /boot/GENERIC copy will be unupdated since it was a manual copy made in its day.

The freebsd-update tool updates /boot/kernel but sometimes only some modules not the entire kernel, resulting in a mix of my custom kernel and GENERIC under /boot/kernel directory, for this reason i have to recompile my custom kernel in each update.

The question is, how can i mantain an updated copy of GENERIC kernel in /boot/GENERIC at the same time i have my custom kernel in /boot/kernel?


----------



## T-Daemon (Apr 7, 2022)

Better keep the GENERIC kernel by its original name /boot/kernel and install the custom kernel under its own name with the INSTKERNNAME variable (see build(7). By doing so the GENERIC kernel won't be touched, /boot/kernel won't be renamed to /boot/kernel.old.

Now freebsd-update(8) can update the GENERIC kernel (/boot/kernel) without touching the custom kernel.

Example:

```
/usr/src # make installkernel INSTKERNNAME=CUSTOM

# ls -d /boot/kernel* /boot/CUSTOM
/boot/CUSTOM /boot/kernel
```

To make the "CUSTOM" kernel default, edit /boot/loader.conf, set variable "kernel" (see loader.conf(5)):

```
kernel=CUSTOM
```



kr0m said:


> i have to recompile my custom kernel in each update.


The above doesn't relieve you from building a new kernel when the GENERIC kernel is binary updated (also src and world, see /etc/freebsd-update.conf) because of security advisories and errata notices.


----------



## SirDice (Apr 7, 2022)

kr0m said:


> When i compile my custom kernel


Maybe it's a good time to review your need for a custom kernel. Most of the time you don't actually need one. If you don't actually _need_ a custom kernel then I would just let things run on the GENERIC kernel. A lot less hassle when updating the system.


----------



## kr0m (Apr 8, 2022)

Thank you T-Daemon, using an alternative kernel name is a good option, it works like a charm, thank you for your support.

SirDice, i want to compile my own kernel because i want to test network interface polling, only for testing and make some network benchmarks.


----------

