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.
mkdir /root/install
cd /root/install
For CVS we use cvsup-without-gui. For installing we use 2 commands:
fetch ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.3-release/Latest/cvsup-without-gui.tbz
pkg_add cvsup-without-gui.tbz
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 host=cvsup.FreeBSD.org
*default base=/usr/local/etc/cvsup
*default base=/usr
*default tag=RELENG_6_2
*default release=cvs delete use-rel-suffix compress
src-all
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.
options PAE
Leave only I686_CPU, because I486_CPU and I586_CPU aren’t necessary on XEON
cpu I686_CPU
I modify ident and i give a name to the server(it need to correspond with the name of the file)
ident server
Add a comment(#) before the line makeoptions DEBUG=-g because i want to minimize the final file:
#makeoptions DEBUG=-g
Deactivate INET6 because i use only INET
#options INET6
Add support QUOTA and the firewall:
options IPFIREWALL
options IPFIREWALL_DEFAULT_TO_ACCEPT
options QUOTA
Now, we go to compile the kernel:
make buildkernel KERNCONF=server
make installkernel KERNCONF=server
After that, restart your pc.
Cheers!
The original article was posted here
Lasă un comentariu