Compiling the Kernel

From Wikislax
Jump to: navigation, search

Compiling the kernel is required whenever you need support for technologies or hardware or options not present in your current kernel. It will also be an opportunity to build a much smaller and more quickly-loading kernel with only the drivers and options that suit your needs and specific configuration.

Compiling the Kernel is a lengthy and painful process. It takes approximately three or four hours to review all the options and their help, and to choose for each option y (yes, to include in the kernel), m (module, to include as a module outside the kernel), or n (no, to not include).

The absence of specific options could cause your kernel not to boot, or some devices would not be available after startup. In most cases, choosing is easy, but here are a few points to specially care for:

  • Include in the kernel the drivers needed to mount your root partition.
  • Include in the kernel the drivers needed to mount your root filesystem.
  • Include in the kernel the drivers to mount filesystems you might need.
  • The tmpfs filesystem is required by udev to populate the device directory.
  • Fuse is needed for the NTFS-3G drivers.
  • The initramfs filesystem seems to be required during startup.

Get the kernel from your distribution at install time, or later on http://www.kernel.org, and install it under /usr/src/linux-x.u.z.t also creating a link from /usr/src/linux. Read the README file and check the prerequisites, that include availability of a development environment. Use make menuconfig to define the kernel options, that will be saved in a text file named .config. Often make security copies of this file. To not lock yourself out, advice is to keep your distribution kernel in place, and to create a second kernel aside. Use «(-xxx) Local version – append to kernel release» to specify a suffix to be appended to the current release string. Then proceed to make and make modules_install (this will install the modules in /lib/modules/x.y.z.t-xxx) but NOT to make install. We don't want it to copy files to /boot.

# make menuconfig
# make
# make modules_install

Instead, copy the compressed kernel image as below:

# cp arch/x86_64/boot/bzImage /boot/vmlinuz-xxx
# cp System.map /boot/System.map-xxx
# cp .config /boot/config-xxx

Then append these lines to /etc/lilo.conf:

# Linux bootable partition config begins
image = /boot/vmlinuz-xxx
  root = /dev/sdaX
  label = Linux-xxx
  read-only  # Partitions should be mounted read-only for checking
# Linux bootable partition config ends

Make sure you have these lines at the beginning of lilo.conf be prompted at boot time which kernel you want to boot (the timeout is in tenth of seconds), man lilo.conf for more info.

Prompt
timeout = 300

Bug : if commenting out the #prompt line, be sure to let a timeout of 1 - as if you put 0 and for some reason the system prompts you then you will enter an infinite loop. That's OK if you are local but this is fatal whenever booting your PC remotely over the network.

Last write the boot sector typing the lilo command. Don't forget to make a copy of your boot record as described in the chapter «Configuring Partitions» and proceed to reboot.

# dd if=/dev/sdaX of=/mnt/win7/Boot/Linux.mbr bs=512 count=1
# sync


X11 over the network Main Page Compiling from Source