← Back to the Blog

Disable debug options in FreeBSD

For all common steps of upgrading FreeBSD to CURRENT and kernel recompilation, please refer to previous post

in this part we will turn off some of debugging options
set by default in FreeBSD CURRENT KERNEL and which can dramatically slow down operating system.

reference


will also be replacing OpenSSL crypto library with LibreSSL ported from OpenBSD it's not yet possible to swtich whole system to LibreSSL, but new ports will get configured using LibreSSL

reference


disable debugging options in KERNEL config file

  • disable WITNESS option in the kernel config file:
  • set MALLOC_PRODUCTION

it's possible to set compilation options through /etc/src.conf

vi /etc/src.conf
MALLOC_PRODUCTION=YES
WITHOUT_SENDMAIL=YES

and also, we will copy default no-debug config file, check/set any other kernel options before reompilation

cd /usr/src/sys/amd64/conf
cp GENERIC-NODEBUG CUSTOM 
vi CUSTOM

enable LOCK_PROFILING

man LOCK_PROFILING first, example usage

set options LOCK_PROFILING in FreeBSD kernel configuration file before recompiling kernel

cd /usr/src/sys/amd64/conf 
vi CUSTOM 
options        LOCK_PROFILING

recompile and install new kernel and userland

remove any leftovers in /usr/obj before rebuild

cd /usr/ && mv obj obj.old && mkdir obj 
rm -rf obj.old &

now let’s rebuild system from sources

this is a longest part of a whole procedure (can be executed overnight)

as root@builder

cd /usr/src 
make -DMALLOC_PRODUCTION -j8 buildworld 1>/tmp/buildworld-CURR-$(date +%F).log 2>&1 &
make -DMALLOC_PRODUCTION -j8 buildkernel KERNCONF=CUSTOM  1>/tmp/buildkernel-CURR-$(date +%F).log 2>&1 &

make -DMALLOC_PRODUCTION -j8 buildworld 1>/tmp/buildworld-CURR-$(date +%F).log 2>&1 & make -DMALLOC_PRODUCTION -j8 buildkernel KERNCONF=CUSTOM 1>/tmp/buildkernel-CURR-$(date +%F).log 2>&1 &

option LOCK_PROFILING


below steps will require downtime:

stop running services, then install new kernel and userland setting maximum number of jobs parameter to 8 (depends on number of CPU in the system)

make -j8 installkernel KERNCONF=CUSTOM 
make -j8 installworld

check logs for errors and reboot upgraded system


example how to recompile libc library with custom compiler option:

cd /usr/src/lib/libc
make -DMALLOC_PRODUCTION -j8 all install

Be the first to reply