Details: In order to have a specialized kernel, you will need to recompile a kernel with redundant features turned off or compile unfrequently used features as kernel modules, which can later be loaded/unloaded on demand.
Kernel compilation is not as hard as it seems. Rather, it could be addictive sometimes :) Usually, the steps involve: 1) Download a kernel; 2) Configure the kernel; 3) Compile the kernel; 4) Compile the kernel modules; 5) Install the kernel modules and the kernel ; 6) Make changes to GRUB/LILO.
For the purpose of this lab, you are going to compile a minimal Linux
kernel and modules for your virtual machine. Before doing so, you
will need to gather most, if not all, of the information about your
virtual machine, such as the chipsets used by the motherboard, various
controllers used by the graphic card, network card, SCSI, sound card,
etc. Those information can be obtained from the manual of your
motherboard, vendor's website, BIOS as well as the Internet. Also,
the commands such as '/sbin/lspci' and '/bin/dmesg', and log files
such as /var/log/messages
are also good sources of those
information. Write them all down on a piece of paper for your
reference later.
/tmp
directory, and remove them after use.
$ yum install ncurses-devel $ yum install gccUngzip (if it's a .bz2 extension, try to use 'bzip2' instead of 'gzip' with the same options) and untar the kernel under
/usr/src
. Then soft-link the newly created directory
(usually it looks something like linux-x.x.x.x
) to
linux
. Change directory to /usr/src/linux
and run 'make menuconfig'.
Go through each options and unselect/uncheck those that do not apply to
your virtual machine. Save the config before exiting.
Usually, this is an iterative process. Unchecking too many features might cause your kernel unusable. On the other hand, leaving too many would result a bloated kernel.
HINT: Be sure to include initrd (General setup/Initial RAM filesystem and RAM disk support) and LSI Logic Fusion-MPT driver (Device Drivers/Fusion MPT device support/Fusion MPT ScsiHost drivers for SPI) modules. Without them, you would get "kernel panic" message.
Run 'make bzImage' to compile the kernel. 'make help' will show you all the available alternatives.
/boot
while the modules will be installed
under /lib/modules/x.x.x.x
, where x.x.x.x
is
the kernel's version number.
Compare the size of the new kernel and the current kernel. (Note: use 'uname -a' to find out the version of the current kernel). Also, use command 'du' to find out both the size of the new and old module directories. At last, use '/bin/lsmod' to show the loaded modules in the new and old kernel.
/boot/grub/grub.conf
.
Then try to reboot from the new kernel. If everything goes smoothly, ie. the virtual machine boots fine, network works, sound card works, etc., make the new kernel the default kernel in GRUB if you would like your VM to boot off the new kernel over every reboot.