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`
#ver=2.1
#ver=3.1.1

ftp -a ftp://ftp.ee.netbsd.org/pub/NetBSD/NetBSD-$ver/source/sets/syssrc.tgz
#ftp -a ftp://ftp.netbsd.org/pub/NetBSD-archive/NetBSD-$ver/source/sets/syssrc.tgz
#ftp -a ftp://ftp.fr.netbsd.org/pub/NetBSD/NetBSD-$ver/source/sets/syssrc.tgz
#ftp -a ftp://ftp4.fr.netbsd.org/mirrors/ftp.netbsd.org/NetBSD-$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'`

#kernel=ALTQNPF
#kernel=INSTALLMULTI
#kernel=GENERICMULTI
#kernel=SMALLPLUS

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
#EOF

vi $kernel

Eventually take the chance to disable INSECURE,

#options        INSECURE

Make it Multiboot-compliant,

options MULTIBOOT

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

Bare-metal,

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

Troubleshooting

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)

References


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