Compiling the kernel in FreeBSD
Posted by unepetitemonde pe Mai 7, 2008
FreeBSD like other operating systems OpenSource allow us to recompile the kernel how we want. That is a big advantage towards operating systems with closed source-like Ms Windows or commercial UNIX systems.
If you want to install a FAMP (FreeBSD, Apache, MySQL, PHP) server which uses like administration system cPanel/WHM is important to recompile the kernel for add the option QUOTA. QUOTA cannot be included like modulus,therefore is important to be built-in. You can add more useful options like PAE, IPFIREWALL,etc.
We need the sources of kernel. To copy the sources through CVS we need a application which do that. He names cvsup. I make a director /root/install where i work.
For CVS we use cvsup-without-gui. For installing we use 2 commands:
Good, we have all necessary tools for download the sources of kernel. We need saying to cvsup application what we want. For that we make a file named supfile which will contain next lines:
*default release=cvs delete use-rel-suffix compress
or, if you do not use a text editor:
echo ‘*default host=cvsup.FreeBSD.org’ > supfile
echo ‘*default base=/usr/local/etc/cvsup’ >> supfile
echo ‘*default base=/usr’ >> supfile
echo ‘*default tag=RELENG_6_2’ >> supfile
echo ‘*default release=cvs delete use-rel-suffix compress’ >> supfile
echo ‘src-all’ >> supfile
Of course, you need replace cvsup.freebsd.org with a csup server which is so closed to the location of server and RELENG_6_2 need replaced with the corresponding string of installed version. I chose cvsup.freebsd.org because for the moment any mirror from Romania don’t work and i chose RELENG_6_2 because cPanel supports only FreeBSD 6.2-RELEASE or lower.
Now, we need copy the sources:
/usr/local/bin/cvsup -g -L 2 supfile
The cvsup command read the supfile file because it is the parameter and it will download the specified version of source files. The -g option tell to the application to deactivate the support for gui and the -L 2 option indicate the level of returned data while downloading.
After some minutes the sources are downloaded.
We enter in the director which contain the configuration file:
cd /usr/src/sys/`uname -m`/conf/
We copy the GENERIC file with a new name and we’ll modify the copy:
cp GENERIC server
The server file(or GENERIC if you modify directly) can be open with any text file for modify. My favorite is vi or vim. These are the changes:
Add PAE support,if i want to access more than 3GB RAM on i386.
Leave only I686_CPU, because I486_CPU and I586_CPU aren’t necessary on XEON
I modify ident and i give a name to the server(it need to correspond with the name of the file)
Add a comment(#) before the line makeoptions DEBUG=-g because i want to minimize the final file:
Deactivate INET6 because i use only INET
Add support QUOTA and the firewall:
Now, we go to compile the kernel:
make buildkernel KERNCONF=server
make installkernel KERNCONF=server
After that, restart your pc.
The original article was posted here