Most of the time, I re-compile the kernel because of the server hardware comes with more then 4gb of memory. But recently I'm setting up a firewall that need to do traffic shaping, through QoS (Quality of Service). PF's ALTQ feature will do the traffic shaping, but by default, it is not included in the default kernel.
This post will show how to compile custom kernel in FreeBSD so that it includes the ALTQ feature :
Preparation :
- Command to check what kernel versions are loader currently :
uname -a
- Processor architecture based kernel config files are stored in
/usr/src/sys/(arch)/conf/
where (arch) can be i386, alpha, amd64, ia64, powerpc, sparc64, or pc98. - Kernel options are stored in the file /usr/src/sys/conf/NOTES
- Make sure that the kernel source exist in /usr/src. If not, please refer to the post "FreeBSD - How to setup & configure jail with ezjail", "caveat" section
Custom kernel compilations starts here :
- Backup the current bootable kernel :
cp -r /boot/kernel /boot/kernel.BOOTABLE
- Change directory into the kernel config files directory :
cd /usr/src/sys/i386/conf/
- Create a new file (e.g. CUSTOMKERNEL) and put the kernel options in it. As an example, this post is compiling ALTQ (Quality of Service) function into kernel so below are the kernel options needed :
include GENERIC ident kernel_with_ALTQ options ALTQ options ALTQ_CBQ # Class Bases Queuing (CBQ) options ALTQ_RED # Random Early Detection (RED) options ALTQ_RIO # RED In/Out options ALTQ_HFSC # Hierarchical Packet Scheduler (HFSC) options ALTQ_PRIQ # Priority Queuing (PRIQ)
- Compile & build the customer kernel using the kernel option file (CUSTOMKERNEL) we've just created :
cd /usr/src; make buildkernel KERNCONF=CUSTOMKERNEL
- Install the kernel and config files into proper place :
cd /usr/src; make installkernel KERNCONF=CUSTOMKERNEL
Reboot the box so that the new kernel will be loaded. In case the new kernel does not boot, this is how to revert to old kernel (that we just backup) :
- Reboot the box. When the Boot Menu appears, choose option 6, "Escape to a loader prompt".
- When dropped to the "Ok" prompt, execute
boot /boot/kernel.BOOTABLE/kernel
By the way, in order to compile PAE kernel option into a custom kernel, just include
options PAEinto the kernel option file. Reboot the box and it will recognize memory above 4gb. Easy huh :p
Adios !!!
No comments:
Post a Comment