bootstrap:

1) build distribution:

   $ cd /usr/src
   $ ./build.sh -T /opt/tools -O /opt/obj -U distribution

2) apply libc patch:

   $ cd /usr/src
   $ patch < libc.diff

3) install libc includes and rebuild:

   cd /usr/src/lib/libc
   $ /opt/tools/bin/nbmake-i386 OBJDIR=/opt/obj includes
   $ /opt/tools/bin/nbmake-i386 OBJDIR=/opt/obj dependall
   $ /opt/tools/bin/nbmake-i386 OBJDIR=/opt/obj install

4) apply init patch:

   $ cd /usr/src/sbin/init
   $ patch < init.diff

5) unpack ramdisk sources:

   $ cd /usr/src/distrib/i386/floppies
   $ tar xvzf .../ramdisk-cgd.tar.gz

6) adjust ramdisk to your needs (e.g., put a custom cgd config there)

7) build ramdisk:

   $ cd /usr/src/distrib/i386/floppies/ramdisk-cgd
   $ /opt/tools/bin/nbmake-i386 OBJDIR=/opt/obj obj
   $ /opt/tools/bin/nbmake-i386 OBJDIR=/opt/obj dependall

8) build your custom kernel, 3 MB md area should be enough:

   # Enable the hooks used for initializing the root memory-disk.
   options  MEMORY_DISK_HOOKS
   options  MEMORY_DISK_IS_ROOT          # force root on memory disk
   options  MEMORY_DISK_SERVER=0         # no userspace memory disk support
   options  MEMORY_DISK_ROOT_SIZE=6000   # size of memory disk, in blocks
   options  MEMORY_RBFLAGS=0

   # Kernel root file system and dump configuration.
   config   netbsd  root on md0a type ffs

   $ cd /usr/src
   $ ./build.sh -T /opt/tools -O /opt/obj -U kernel=CUSTOM

9) put name of your kernel into ramdisk-cgd/Makefile.kernel and build image:

   $ cd /usr/src/distrib/i386/floppies/ramdisk-cgd 
   $ /opt/tools/bin/nbmake-i386 OBJDIR=/opt/obj -f Makefile.kernel