How to compile kernel
Compiling Linux kernel is an essential skill that most Linux users should have, since default kernel is not optimized for your own system. It should be noted that the default kernel that ships with Salix OS is "generic" and will work in most cases, and no recompiling is necessary. You should only recompile if:
- Your system's hardware is not supported by the default kernel
- You need (want) features only available in newer kernel
- You want to make the OS truly for your own system
As much as it sounds complicated and dangerous, if you follow the following steps, it is not hard at all. Note that all of this should be done with root privilege.
Preparation
First, download appropriate kernel source from http://www.kernel.org
Unpack source into /usr/src/ and symlink /usr/src/linux to that directory
ln -s /usr/src/linux-3.2.35 /usr/src/linux
Then go into that directory, and do
make mrproper
This is sort of cleaning procedure and will set everything to default. You can work from here, but it is highly recommended to use the working configuration (i.e. the one you've been running on). The default kernel config is found in /proc/config.gz, so copy this file:
zcat /proc/config.gz > .config
Next, you configure your kernel. You have several options:
make menuconfig
will bring up the ncurses based menu-driven config. If you rather, you can do
make xconfig
to bring up the qt-based config, or
make gconfig
to bring up the gtk-based config.
Compiling
Once you have configured the kernel to your liking, save and exit. Then do:
make
to build the kernel. This will take some time. After it's done, do:
make modules_install
to install all of the modules. All of the modules will be installed under /lib/modules/version, where 'version' corresponds to the version of the kernel compiled.
Finalizing
Next is to copy the created kernel image and system map to the boot directory.
cp -v arch/x86/boot/bzImage /boot/vmlinuz-version cp -v System.map /boot/System.map-version
where 'version' corresponds to the version of the kernel compiled
Next you want to create initrd.gz file.
/usr/share/mkinitrd/mkinitrd_command_generator.sh -l /boot/vmlinux-version
will generate a command that you can then copy and paste. By default, it will output to /boot/initrd.gz. You may want to change this when cutting and pasting so that it will output to /boot/initrd-version.gz.
As a final step, edit /etc/lilo.conf so that it will see the newly created kernel:
image = /boot/vmlinuz-version root = /dev/sda6 initrd = /boot/initrd-version.gz label = "New Kernel" read-only
Don't forget to run
lilo
to take effect of the new configuration.
That's it. When you reboot, you should see the new kernel is the lilo menu, and everything should work. As a check, after the system reboots itself:
uname -a
You should see that the kernel version is indeed what was just made.