Thursday, October 22, 2009

To Compile Linux Kernel 2.6.18.8

I restored my old backup of Debian Linux to a JFS partition on my Toshiba NB205 netbook. Then, I wanted to build a kernel optimized for my netbook. However, the latest version of Linux kernel seems to be unstable. So I compiled Linux kernel 2.6.18.8 which I believe is still usable and stable, though a bit outdated. Before compiling a Linux kernel, some packages should be installed.



  • binutils
  • gcc-3.4
  • libglade2-dev
  • make
  • module-init-tools
  • patch

libglade2-dev is needed to compile and run a kernel configuration tool with the command “make gconfig”. I downloaded the source for Linux kernel 2.6.18.8 from the kernel.org FTP server and unpacked it.


tar xzf linux-2.6.18.8.tar.gz
cd linux-2.6.18.8

I am going to add the following features to the kernel:



  • unionfs is a pseudo-filesystem that implements a transparent multi-layer filesystem that's made up of real filesystems. I use it to make a live Linux CD-ROM. The patch for kernel 2.6.18.8 is unionfs-2.5.3_for_2.6.18.8.diff.gz.
  • squashfs is a compressed read-only filesystem. I'll use it for my Web-only Linux system.
  • ndiswrapper will be used to set up network interface cards with Windows drivers. The latest version 1.55 will be used.

Then, I patched the kernel source with unionfs and squashfs:



gzip -dc unionfs-2.5.3_for_2.6.18.8.diff.gz | patch -p1 -l
tar xzf squashfs3.4.tar.gz
patch -p1 -l < squashfs3.4/kernel-patches/linux-2.6.18/squashfs3.4-patch


Then, I copied the config file of an older or running kernel to the kernel source folder.


gzip -dc /proc/config.gz > .config

Then I typed the following command to start a graphical kernel configurator:


make gconfig

I compiled the kernel with the following commands:


make bzImage
make install
make modules
make modules_install

“make modules” took more than an hour to finish. I went to the /boot directory and typed the following commands:


cd /boot
rdev vmlinuz-2.6.18.8 1,0
ramsize vmlinuz-2.6.18.8 2048

The commands above will set the default root device to ramdisk /dev/ram0 and limit the ramdisk size to 2048KB.


Then, I went ahead to create an initrd image for booting with the new kernel. After rebooting with the new kernel, I compiled ndiswrapper and squashfs tools. If you get a ntoskrnl error when compiling ndiswrapper 1.55, apply the following patch:


diff -urN ndiswrapper-1.55-orig/driver/ntoskernel.h ndiswrapper-1.55/driver/ntoskernel.h
--- ndiswrapper-1.55-orig/driver/ntoskernel.h 2009-06-28 16:09:27.000000000 -1000
+++ ndiswrapper-1.55/driver/ntoskernel.h 2009-10-10 21:11:16.363610279 -1000
@@ -875,7 +875,7 @@
#define u64_low_32(x) ((u32)x)
#define u64_high_32(x) ((u32)(x >> 32))

-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+//#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
static inline u64 cmpxchg8b(volatile u64 *ptr, u64 old, u64 new)
{
u64 prev;
@@ -887,7 +887,7 @@
: "A" (old), "b" (u64_low_32(new)), "c" (u64_high_32(new)));
return prev;
}
-#endif
+//#endif

/* slist routines below update slist atomically - no need for
* spinlocks */

I used the following commands to compile ndiswrapper and squashfs tools.


cd squashfs3.4/squashfs-tools
make
cp mksquashfs unsquashfs /usr/local/bin
cd ../../ndiswrapper-1.55
make uninstall
make
make install

Thus a linux kernel 2.6.18.8 has been compiled. The following files and folders are created after this.


/boot/System.map-2.6.18.8
/boot/config-2.6.18.8
/boot/vmlinuz-2.6.18.8
/lib/modules/2.6.18.8/
/sbin/loadndisdriver
/usr/local/bin/mksquashfs
/usr/local/bin/unsquashfs
/usr/man/man8/loadndisdriver.8
/usr/man/man8/ndiswrapper.8
/usr/sbin/ndiswrapper
/usr/sbin/ndiswrapper-buginfo


Related Posts


No comments:

Post a Comment

About This Blog

KBlog logo This blog is about current events and issues concerning general population. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger