Purpose of this howto

At some time, due security issues or just fun, the netbsd kernel has to be recompiled 
with the latest patches and then this document becomes useful.

Well at the moment of writing the latest netbsd release is the 2.0.2, so this document is applicable just for that release.

This document is written in a way to be used for the coming releases as well.

*) Download the kernel sources 

Well, U can always download the generic kernel and stick with it. Simple and easy.

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-daily/{BRANCH}/{DATE}/i386/binary/kernel/{ARCH}/binary/kernel/netbsd-GENERIC.gz

Ex: /pub/NetBSD-daily/netbsd-2/200508160000Z/i386/binary/kernel/ netbsd-GENERIC.gz

Usually, I want to do most of the things myself ,so I’ll go the hard way.

There are many different ways to grab the kernel sources , sup , anoncvs, etc. I use ftp:

# ftp anonymous@ftp.netbsd.org

Then  cd to the sources in tar files,

#cd /pub/NetBSD/NetBSD-release-2-0/tar_files/src

get the tar files that I need,

# mget  config.tar.gz  contrib.tar.gz sys.tar.gz

Disconnect

#by

Usually I ftp from the /tmp folder. 
The important thing is start the ftp from a place you know and with a file system with enough disk space.

Then I cd to /usr ( because of the tar files has to be unzipped there) and  I go:
# tar zxvf /tmp/ config.tar.gz 
# tar zxvf /tmp/ contrib.tar.gz
# tar zxvf /tmp/ sys.tar.gz
At this moment  I have all the needed sources to compile my own kernel.

*) Compile the kernel

This part is very straightforward. My arch now is i386, so I go.

# cd src/sys/arch/i386/conf

I copy the GENERIC to MYNEWKERNEL  and make the changes
# cp GENERIC MYNEWKERNEL 

I edit MYNEWKERNEL according to my hardware and needs and save it.
Now we can start with the fun part.
# config MYNEWKERNEL
# cd ../compile/ MYNEWKERNEL
# make depend && make
I make a copy of my old kernel , just in case.

# mv /netbsd /netbsd.old

Then I copy my brand new kernel to its place

# mv netbsd /netbsd

and reboot and cross my fingers

# reboot


*) If something went wrong ?

We had backup copy of our old kernel. Then I  boot my 'netbsd.old' kernel in single user mode. 
Press SPACE when the first netbsd message appears

# boot netbsd.old -s

Then copy your kernel back: 
# fsck /
# mount /
# mv netbsd.old netbsd
# exit
Sugestions? mail them to tonyex@yahoo.com