Recompile Kernel FreeBSD Release To Stable | Update and Upgrade

FreeBSD-CURRENT represents the "bleeding edge" of FreeBSD development, and users must have a high level of technical expertise. Less technical users who want to follow the development branch should go with FreeBSD-STABLE.

FreeBSD-CURRENT contains work in progress, experimental modifications, and transition mechanisms that may or may not be included in the next official version. Despite the fact that many FreeBSD engineers compile FreeBSD-CURRENT source code regularly, there are a few brief instances when the source code cannot be built. This issue is addressed as quickly as possible, however, whether FreeBSD-CURRENT provides a disaster or a new feature depends on when the source code is synchronized.

In this article we will learn how to update the FreeBSD kernel from the Release/Current version to FreeBSD Stable. Before updating, first check the FreeBSD system version.

root@ns1:~ # uname -a
FreeBSD ns1 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64
Currently we are using FreeBSD 13.2 RELEASE. We will update this version to the FreeBSD Stable version. In the old version of FreeBSD, subversion was used to update the FreeBSD kernel. Gradually, as it continued to develop and the number of FreeBSD users, they changed to git to update the kernel.
Before starting the FreeBSD kernel update, delete the /usr/src folder.
root@ns1:~ # rm -rf /usr/src/*
root@ns1:~ # rm -rf /usr/src/.*
To start updating the FreeBSD kernel with git, you must clone the FreeBSD Stable file. Follow these steps to download files with Git.
root@ns1:~ # pkg install git
root@ns1:~ # git clone -b stable/13 --depth 1 /usr/src

The script above will install the git application and the second script will download the files used to update the kernel. The file is stored in the /usr/src folder. After successful downloading, continue with the script below.
root@ns1:~ # cd /usr/src
root@ns1:/usr/src # git pull && git branch --all

1. Edit GENERIC File

The main file for compiling the kernel is called GENERIC which is in the /usr/src/sys folder, which can also be accessed via /sys. There are a number of subdirectories here that represent different sections
kernel, but most important, for our purposes, are the conf folder, a folder for editing custom kernel configurations, and applications.

In this folder, we must determine what machine we are using, in this article, the FreeBSD system is built on an AMD64 computer, so the folder we will use is /usr/src/sys/amd64/conf. Note the word amd64 before the conf folder. If your computer uses the i386 architecture then use the /usr/src/sys/i386/conf folder. In this folder the GENERIC file is located.

You can edit GENERIC files according to your FreeBSD computer engine. GENERIC files contain computer hardware kernels such as processors, sound cards, land cards, motherboards, not only that, application program kernels are also stored in GENERIC files. In this example we will edit the GENERIC file for creating a Firewall Router (Gateway). Because the Router Firewall is closely related to the packet filter firewall and ipfw firewall applications, we must compile the firewall kernel in a GENERIC file. Add the following script to the /usr/src/sys/amd64/conf/GENERIC file to compile the firewall kernel.
device		    bpf
options IPDIVERT
options LIBALIAS
options DUMMYNET
options HZ="1000"
options MROUTING
device coretemp

options ALTQ
options ALTQ_CBQ
options ALTQ_RED
options ALTQ_RIO
options ALTQ_HFSC
options ALTQ_PRIQ

device pf
device pflog
device pfsync
Next, backup the GENERIC kernel, in this case we will copy the GENERIC file to a file called "ROUTERSIUDIN".
root@ns1:~ # cd /usr/src/sys/i386/conf
root@ns1:/usr/src/sys/i386/conf # cp GENERIC ROUTERSIUDIN

Compile File GENERIC

After the GENERIC file has been edited and backed up, now the FreeBSD kernel with the name "ROUTERSIUDIN" is ready to be compiled. Before compiling the ROUTERSIUDIN kernel, write an iden script like the following.

ident		GENERIC
replace with,

After that, compile the ROUTERSIUDIN kernel. Use the following script to compile the ROUTERSIUDIN kernel.
root@ns1:~ # cd /usr/src
root@ns1:/usr/src # make buildworld KERNCONF=ROUTERSIUDIN
The script above will build the world kernel routersiudin, after doing buildworld continue with.
root@ns1:/usr/src # make buildkernel KERNCONF=ROUTERSIUDIN
root@ns1:/usr/src # make installkernel KERNCONF=ROUTERSIUDIN
root@ns1:/usr/src # make installworld KERNCONF=ROUTERSIUDIN
root@ns1:/usr/src # reboot
After the restart/reboot process is complete, check the FreeBSD version with the script below.
root@ns1:~ # uname -a
This kernel compile time is quite long, a computer with an Intel Core(TM)2 Duo E8400 @ 3.00GHz processor takes approximately 20 hours. If you compile the kernel during the day tomorrow morning it will be finished. So how long the kernel compilation process takes depends on the computer processor.

Compiling source code for FreeBSD kernel updates has various benefits versus binary updates. Code can be created using that option allows us to use certain hardware. System elements base can be built with non-default settings or omitted if neither necessary nor preferred.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post