mercredi, juin 05, 2013

Generating custom FreeBSD installation media


Objective

Generating a custom -current memstick image without all the debug feature enabled.

Prerequisite

Have the head source installed (I will use /usr/src as example).
If not, here is an example for synchronizing up-to-date head (-current) sources on /usr/src
svn co svn://svn.freebsd.org/base/head /usr/src

Customizing kernel configuration file

-current kernel have lot's of extra debug features enabled and I need netmap: Then I will create a customized kernel configuration file.
cat > /usr/src/sys/amd64/conf/PROD <<EOF
include         GENERIC
ident           PROD

nooptions    DEADLKRES
nooptions    INVARIANTS
nooptions    INVARIANT_SUPPORT
nooptions    WITNESS
nooptions    WITNESS_SKIPSPIN
nooptions    MALLOC_DEBUG_MAXZONES

device       netmap
EOF

Customizing build compilation options

There is still another  debug feature to disable on -current:
echo "MALLOC_PRODUCTION=yes" > /etc/src.conf

Building world and kernel

New we start the classical building of world and our customized kernel.
For information this step takes about 4 hours on my PC.
cd /usr/src
make buildworld; make buildkernel KERNCONF=PROD

Generating install media image

Last step: Generating the install media.
Here is an example for generating memstick install media without port tree (long live to pkgng! neither doc):
cd /usr/src/release
make -DNOPORTS -DNODOC memstick


Replace "memstick" by "cdrom" (bootonly.iso and release.iso) or "ftp" for other media.
You can add a -DNOSRC option for avoiding to include sources too on the media.

Then copy the image to your usb key:
dd if=memstick of=/dev/da0 bs=64k

Cleaning your mess

Your system has lot's of file that you don't need anymore, here is how to clean it:
cd /usr/src/release
make clean
cd /usr/src
make clean



Enregistrer un commentaire