Compiling the NetBSD kernel

Make sure you have enough RAM (7168MB is fine), and eventually increase the number of vcpus.

Fetching and extracting the very release version that you are running,

mkdir -p /data/build/
cd /data/build/

ver=`uname -r`

ftp -a$ver/source/sets/syssrc.tgz
#ftp -a$ver/source/sets/syssrc.tgz
#ftp -a$ver/source/sets/syssrc.tgz
#ftp -a$ver/source/sets/syssrc.tgz
progress -zf syssrc.tgz tar xf -

Handy symlinks,

ls -lhF /usr/src
rm -f /usr/src
ln -s ../data/build/usr/src /usr/src

ls -lhF /root/src
rm -f /root/src
ln -s ../data/build/usr/src /root/src

Tweaking the kernel configuration,

#echo ${HOST%%\.*}
#kernel=`echo ${HOST%%\.*} | tr 'a-z' 'A-Z'`


cd /usr/src/sys/arch/`uname -m`/conf/
cp -pi GENERIC $kernel
#cp -pi XEN3_DOMU $kernel
#cp -pi INSTALL_SMALL $kernel
#cat >> $kernel <<-EOF
#nfe*    at pci? dev ? function ?        # NVIDIA nForce Ethernet

vi $kernel

Eventually take the chance to disable INSECURE,

#options        INSECURE

Make it Multiboot-compliant,


Enaling ALTQ,

#altq available options as for netbsd 8.0
options         ALTQ            # Manipulate network interfaces' output queues
options         ALTQ_BLUE       # Stochastic Fair Blue
options         ALTQ_CBQ        # Class-Based Queueing
options         ALTQ_CDNR       # Diffserv Traffic Conditioner
options         ALTQ_FIFOQ      # First-In First-Out Queue 
options         ALTQ_FLOWVALVE  # RED/flow-valve (red-penalty-box)
options         ALTQ_HFSC       # Hierarchical Fair Service Curve
options         ALTQ_LOCALQ     # Local queueing discipline
options         ALTQ_PRIQ       # Priority Queueing 
options         ALTQ_RED        # Random Early Detection
options         ALTQ_RIO        # RED with IN/OUT
options         ALTQ_WFQ        # Weighted Fair Queueing

Enabling NPF,

pseudo-device   npf                     # NPF packet filter 

options         NPF_EXT_LOG     
options         NPF_EXT_NORMALISE 
options         BPFJIT
options         SLJIT

In case this is bare-metal and not a XEN nor serial console,

options         WS_KERNEL_FG=WSCOL_BROWN
#options         WS_KERNEL_FG=WSCOL_RED

Note: there is no YELLOW.

grep WSCOL /usr/src/sys/dev/wscons/wsdisplayvar.h

Compiling the new kernel,

cp $kernel /data/build/
diff -bu GENERIC $kernel > /data/build/$kernel.diff

#ls -alhF ../compile/$kernel/
#rm -rf ../compile/$kernel/
config $kernel

dmesg | egrep ^[v]?cpu

cd ../compile/$kernel/
time make -j16 depend > /data/build/$kernel.make.depend.log && echo SUCCESS
tail /data/build/$kernel.make.depend.log 

#make clean
time make -j16 > /data/build/$kernel.make.log && echo SUCCESS # 238.26s
tail /data/build/$kernel.make.log


mv /netbsd /netbsd.old
cp /usr/src/sys/arch/`uname -m`/compile/$kernel/netbsd /
shutdown -r now

XEN host,

scp bsdbuild:/usr/src/sys/arch/amd64/compile/ALTQNPF/netbsd netbsd.altqnpf
scp bsdbuild:/usr/src/sys/arch/amd64/compile/GENERICMULTI/netbsd netbsd.genericmulti

XEN guest,

shutdown -p now

and change its settings to point to the new kernel,

kernel = "/data/kernels/netbsd8/altqnpf"

At system startup, watch the console and check,

dmesg | grep ^NetBSD
uname -a


make[1]: don't know how to make absvdi2.c. Stop

==> either use config -s or put your sources folder in the default location (/usr/src)


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml