Most NetBSD users will, sooner or later, compile a customized kernel. This gives you several benefits:
you can dramatically reduce kernel size and, therefore, memory occupation (for example, from 2.5 MB to 1.2 MB). On version 1.5 of NetBSD compiling a custom kernel reduced the size from 4.7 MB to 1.9 MB.
you can improve performance.
you can tune the system.
you can solve problems of detection/conflicts of peripherals.
you can customize some options (for example keyboard layout, BIOS clock offset, ...)
you can get a deeper knowledge of the system.
You can get the kernel sources from the same source where you got your installed system (for example ftp://ftp.netbsd.org.) Remeber to download the sources for the release you are running. |
# gzip -dc syssrc.tgz | (cd / ; tar xvf -)
# cd /usr/src/sys # cd /sys
static const keysym_t pckbd_keydesc_it[] = { ... KC(8), KS_7, KS_slash, KS_braceleft, KC(9), KS_8, KS_parenleft, KS_bracketleft, KC(10), KS_9, KS_parenright, KS_bracketright, KC(11), KS_0, KS_equal, KS_braceright, KC(12), KS_apostrophe, KS_question, KS_grave, KC(13), KS_igrave, KS_asciicircum, KS_asciitilde, KC(26), KS_egrave, KS_eacute, KS_bracketleft, KS_braceleft, KC(27), KS_plus, KS_asterisk, KS_bracketright,KS_braceright, ...
To recompile the kernel you must have installed the compiler set (comp.tgz).
# cd /sys/arch/i386/conf/ # cp GENERIC MYKERNEL # vi MYKERNEL
The modification of a kernel configuration file basically involves three operations:
<XXX> at <YYY>
options RTC_OFFSET=-60 ... options PCKBD_LAYOUT="KB_IT"
The adjustkernel Perl script, which is available in the package system (pkgsrc/sysutils/adjustkernel), analizes the output of dmesg and automatically generates a minimal configuration file. To run it you need to have Perl installed on your system. The installation of new software is described in detail in the Chapter 8. If you want to install Perl now, download the pre-compiled package perl-5.00404.tgz and write the following command:
# pkg_add perl-5.00404.tgz
Now Perl is installed, configured and ready to work: easier than this it's impossible...
You can now run the script with:
# cd /sys/arch/i386/conf # perl adjustkernel GENERIC > MYKERNEL
I tried this script and it worked very well, saving me a lot of manual editing. Beware that the script only configures the available devices: you must still configure manually the other options (eg. Linux emulation, ...)
Dependencies generation and kernel compilation is performed by the following commands:
# cd ../compile/MYKERNEL # make depend # make
# mv /netbsd /netbsd.old # mv netbsd /
-rwxr-xr-x 1 root wheel 1342567 Nov 13 16:47 /netbsd -rwxr-xr-x 1 root wheel 3111739 Sep 27 01:20 /netbsd.old
The new kernel is activated after rebooting:
# reboot