April 19, 2010

FreeBSD remote kernel testing

 

FreeBSD 7 remote kernel testing

If your server is located at a remote location and you have just built a custom kernel, then there is a handy feature in FreeBSD that will allow you to test your new kernel without breaking the entire system.

The commands (including the make command for the kernel) are as follows:

# cd /boot

# cp -R kernel kernel.good

# cd /usr/src

This will install the kernel in /boot/kernel

# make KERNCONF=MYKERNELNAME buildkernel

# cd /boot

# mv kernel kernel.mykernelname

# mkdir kernel

# cp kernel.good/* kernel/

# nextboot -k kernel.mykernelname

 

Upon reboot, the system will load kernel.mykernelname and then erase the part of the configuration that told it to load kernel.mykernelname

Consequently, subsequent reboots will load the kernel located in /boot/kernel which is the original kernel

Assuming that kernel.mykernelname loaded successfully, you can run the following commands to make the new kernel permanent:

# mv /boot/kernel /boot/kernel.previous

# mv /boot/kernel.mykernalname /boot/kernel