Posted 08.08.2005 | Updated 23.05.2006 | Contributed by Brad Robinson & Andy Mallett
The Kernel is the heart of the OS and controls memory, most hardware devices, processor requests, disk management, etc.
Some people like to fiddle and some fiddlers like to recompile their kernel.
The benefits of getting rid of unwanted drivers includes faster boot time and lower memory usage. It may also be necessary to recompile to add newer hardware support, like graphics drivers, soundcard, etc.
Generally the smaller and faster the kernel, the faster the system will wizz along.
|
|
Prerequisites
Also ensure all existing hardware in the system is known. You will need to be able to recognise necessary drivers for various makes and models of hardware.
Ensure the Kern Developer option was chosen during install. If you don't have a directory named /usr/src/sys/1386/conf, the kernel source has not been installed. To install the kernel source run:
sysinstall
Select configure | distributions | source | sys. Follow the prompts to install the kernel source.
Preparation: Configuring the Kernel File
cd /usr/src/sys/i386/conf
Copy the file GENERIC to a new file called MYKERNEL (name must be in capital letters, no longer than 10 letters)
Edit MYKERNEL with vi. You must make a change to the ident line near the top of the file. Replace the value GENERIC with the name of your new kernel (MYKERNEL in this case).
Next go through the file and hash out any references to hardware that does not exist on your system, i.e. hash out unwanted NIC card, SCSI and RAID stuff.
Note, under Network card section, you must leave the device miibus entry
Under #SCSI peripherals - leave device scbus and device da
Make sure to read all of the hints in the kernel config file. If you are unsure of an option, leave it as is.
Save your new kernel file and exit the editor.
Compiling the Kernel
Time for the big one.
Make sure you are in the /usr/src/sys/i386/conf directory where the new kernel file you copied lives. Run the following commands:
/usr/sbin/config MYKERNEL
This will generate the new kernel source code and send the message below to the screen.
The Kernel build directory is ../compile/MYKERNEL
cd ../compile/MYKERNEL
This redirects you into the new build directory. Now its time to actually compile the kernel. Run the commands below one at a time on the command line.
make depend
make
This will compile the new kernel.
make install
This will install the new kernel
After the compile finishes reboot the system with the new kernel. The system kernel should take less time to boot, because the system is not loading stacks of unwanted device drivers.
Buggerit!
If the kernel won't boot, try using the old kernel (GENERIC.OLD). To do this, hit any key as the computer counts down to boot time (DO NOT HIT ENTER). Type:
unload
and then
boot kernel.old
This should allow you to boot the old kernel GERERIC so that you can access the system to make any changes to your config.
You will also need to re-mount the file system in read/write mode..
mount -w /
to remount your root filesystem in read/write mode
- B&A.
|
|