FreeBSD · FreeBSD 10.0

Building and Installing custom kernel in FreeBSD-10

Go to the kernel source directory which contains the configurations.

cd /usr/src/sys/amd64/conf

Create a folder named kernel in the home directory of root user i.e. /root.

mkdir /root/kernels

Create a soft link in the /usr/src/sys/amd64/conf named “MYKERNEL” which links to /root/kernels/MYKERNEL file.

cp GENERIC /root/kernels/MYKERNEL
ln -s /root/kernels/MYKERNEL

Goto the folder created above.

cd /root/kernels/

Edit the file “MYKERNEL” and make the following change. This line helps us to create the new kernel which is a combination of a generic kernel and the extra features added. The following line includes the features available in a generic kernel

include         GENERIC

The other additional lines specify the features to be added in the kernel to be created.
For Example:

cpu             HAMMER
ident           GENERIC

makeoptions     DEBUG=-g                # Build kernel with gdb(1) debug symbols
makeoptions     WITH_CTF=1              # Run ctfconvert(1) for DTrace support

options         SCHED_ULE               # ULE scheduler
options         PREEMPTION              # Enable kernel thread preemption
options         INET                    # InterNETworking
options         INET6                   # IPv6 communications protocols
options         TCP_OFFLOAD             # TCP offload
options         SCTP                    # Stream Control Transmission Protocol
options         FFS                     # Berkeley Fast Filesystem
options         SOFTUPDATES             # Enable FFS soft updates support
options         UFS_ACL                 # Support for access control lists
options         UFS_DIRHASH             # Improve performance on big directories
options         UFS_GJOURNAL            # Enable gjournal-based UFS journaling
options         QUOTA                   # Enable disk quotas for UFS
options         MD_ROOT                 # MD is a potential root device

To build a file which contains all available options, run the following commands.

cd /usr/src/sys/amd64/conf
make LINT

Goto the main source folder.

cd /usr/src

Build and Install the new kernel with reference from the file “MYKERNEL”.

make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL

Now reboot the machine to boot into the new kernel you just created now.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s