Build Custom Kernel

From wiki
Jump to navigation Jump to search

Previous post install actions Return ssh configuration


Build Custom kernel with ALTQ for firewalls

First ensure the custom kernel configuration files are downloaded in the ~/conf/kernels directory. We use the methode of having a source file with the specifics only, which includes the GENERIC file. In the firewall case we used GENERIC_STRIPPED which is the GENERIC file with unused options and hardware commented out to reduce Kernel compilation time. Then make a folder in the boot directory where we will store the configuration files for the host specific kernel.

>$ cd ~/conf/kernel
>$ su
># mkdir /boot/kernels
># cp CUSTOM_V040 /boot/kernels/
># cp GENERIC_STRIPPED /boot/kernels/

Make a copy of the current generic kernel, if this is the first build. This will allow to boot in the generic kernel if the custom kernel doesn't boot. The install will make a kernel.old but that is overwritten with each install

># cp -pr /boot/kernel /boot/kernel.generic

Make now links from the kernel source directory to the kernel configuration files in the /boot/kernels directory.

># cd /usr/src/sys/amd64/conf
># ln -s /boot/kernels/GENERIC_STRIPPED ./GENERIC_STRIPPED
># ln -s /boot/kernels/CUSTOM_V040 ./CUSTOM_V040

Go to the root of the src directory and switch to screen so you can detach it to let it run from a ssh session.

># cd /usr/src/
># screen

Start the build in screen and detach from the screen when the build process runs.

># make buildkernel KERNCONF= CUSTOM_V040
...
[ctrl]A d

The build process can be checked and then detached again. Until the build has been successfully completed.

># screen -r
...
--------------------------------------------------------------
>>> Kernel build for CUSTOM_V040 completed on Sun Jan 12 15:22:36 CST 2020
--------------------------------------------------------------

Then install the kernel with

># make installkernel KERNCONF= CUSTOM_V040
....
--------------------------------------------------------------
>>> Installing kernel CUSTOM_V040 completed on Sun Jan 12 16:11:53 CST 2020
--------------------------------------------------------------

Now reboot into the new kernel.

># exit
>$ sudo shutdown -r now && exit

Previous post install actions Return ssh configuration

Up Freebsd Knowledge Base