In this post I am going to discuss methods to reduce the size of Freebsd kernel.
1) Configuring kernel: –
In FreeBSD kernel many unused options are added by default which make the size of kernel large. By removing those options from kernel we can make the size of kernel reduce.
How we should do it ?
Step 1: First of all we have to download the Freebsd Source Code in /usr/src directory
Step 2: After Downloading the Freebsd Source Code make a symbolic link to /usr/src/sys
# ln -s /usr/src/sys /sys
Step 3: Change your working directory to /usr/src/sys/i386/conf
# cd /usr/src/sys/i386/conf
Step 4: Don’t Edit Generic Directly. Keep kernel configuration file elsewhere & creat a sybolic link to the file
# cd /usr/src/sys/i386/conf
# mkdir /root/kernels
# cp GENERIC /root/kernels/MYKERNEL
# ln -s /root/kernel/MYKERNEL
Step 5: Edit the file MYKERNEL and the file MYKERNEL in /root/kernels will automatically get change because of Symbolic link of MYKERNEL is created. The advantage of it is your changes will be saved on file MYKERNEL in /root/kernels and if you some how delete your /usr/src folder or update system your changes will not get lost as they are saved in file MYKERNEL at /root/kernels and you can restore your changes.
Step 6: Build the MYKERNEL
# cd /usr/src
# make bulidkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL
NOTE: To update kernel faster edit /etc/make.conf
a) MODULES_OVERRIDE= linux acpi sound/driver/ds1 ntfs
This variable specifies list of of module build instead the default building of all of them.
b) WITHOUT_MODULES= linux acpi sound ntfs
Build kernel without these module.