How to compile the Kernel for your Intel Mac computer

Posted on December 9, 2008

Compiling the kernel is an advanced  topic and warrants a bit of a warning.

For any reader that has ever compiled a kernel before we can say that “Compiling a Kernel” isn’t as daunting as the terminology sounds. Benefits of a correctly compiled kernel can result in a leaner kernel that can provide performance increases over the generic, pre-configured Ubuntu kernel. Though this howto is basically a part of different readings in various Linux forums it is mostly derived from xXx 0wn3d xXx’s excellent kernel compile howto. I’d like to thank all for their part.

Below is a step by step guide about how to do it.

1. Su to root:

Code:
sudo bash

2. Install the needed utilities and libraries to configure the kernel:

apt-get install build-essential bin86 kernel-package libqt3-headers libqt3-mt-dev libncurses5 libncurses5-dev

3. Change to the directory where we will work with the kernel:

cd /usr/src

4. Download the kernel. Visit kernel.org to see what kernels are available. If you want to use a stable kernel build don’t choose a release canidate(rc) version as these are meant for testing. To grab a kernel wget works nice to retrieve it. For Example:

wget http://kernel.org/pub/linux/kernel/v2.6/linux-<version>.tar.bz2

5. Next unpack it:

tar -xvf linux-<version>.tar.bz2

6. Remove the symbolic link to the kernel if and previous kernels have been compiled:

rm -rf linux

7. Create a new link to the new kernel source.

ln -s /usr/src/linux-<version> linux

8. Subversion is required to download the mactel kernel patches.

apt-get install subversion

9. Download the Kernel Patches by filling in the appropriate kernel version:

Most patches eventually make the kernel tree and patching may not always be necessary.

svn co https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/kernel/mactel-patches-<version>

10. Enter the patches Directory:

cd mactel-patches-<version>

11. and patch the kernel:

./apply /usr/src/linux

12. Now change to the unpacked kernel source directory:

cd ../linux

13. The kernel configuration file is a key to how well the kernel will run (if at all). Research your computer and discover what hardware it has and apply the appropriate drivers to the kernel. Also some people post their custom configurations. Use these with care. An updated .config file can be found in various places. The Gentoo Linux Wiki keeps pretty up to date ones:

Use your favorite editor and save the configuration.

Now, move and rename the kernel configuration to the Linux kernel source directory (/usr/src/linux):

mv config-<version> /usr/src/linux/.config

15. If kernel .config is older than the current version of the kernel it needs to be updated:

make oldconfig

make oldconfig will ask a series of questions if the kernel version differs from the config version this is safe to do and should be done if even we are pretty sure the version matches. A series of questions will be prompted for differing configuration options. In most cases it is safe to hit enter for the default though it is best to look into what they do, type in a question mark for additional information.

16. Now configure the kernel for the Intel-Mac:

make menuconfig

I like make menuconfig but a graphical interface is also available:

make xconfig

Choose the option “Save to Disk” when ready.

17. Be sure to begin with a clean enviroment before beginning compiling (this is only necessary if the kernel has been compiled before):

make-kpkg clean

18. Now it’s time to compile the kernel, it’s headers, and modules all into a Debian Packages all in one easy step:

make-kpkg -initrd kernel_image kernel_headers modules_image

19. Compiling  kernel will take awhile so go enjoy a jolt.

When compiling is done, go back to /usr/src directory, where the Debian Packages are saved.

cd ..

The kernel Debian Packages will be seen here and now we can install them. If their are multiple versions here make sure to fill in the right version.

dpkg -i linux-image-*.Custom_i386.deb
dpkg -i linux-headers-*.Custom_i386.deb

Popularity: 1% [?]

Related Posts:

» Filed Under Linux

Comments

Leave a Reply